I'm facing a puzzling issue while managing Active Directory account expiration dates through PowerShell. In my script, I calculate the expiration date like this: `$expirationDate = (Get-Date).Date.AddDays($DaysOffset).AddHours(12)`, where `$DaysOffset` is a user-defined parameter with a default of `-1`. This means that when I execute the script on **January 25**, I anticipate the expiration date to be set for **January 24 at 12:00 PM**. When applying this to each user, PowerShell confirms the expiration is indeed set correctly; it shows **January 24, 12:00 PM**. Additionally, when I use `Get-ADUser`, it reflects the correct value of **24.01.2026 12:00:00**. However, when I open Active Directory Users and Computers (ADUC), I notice that the **Account Expiration Date** shown in the GUI is **January 23** instead of **January 24**. It seems there's a discrepancy between PowerShell and the GUI. Can anyone help me understand why this is happening? Thanks for your assistance!
3 Answers
I suspect the issue is with how you're adding hours after applying the offset. Try separating those operations; first, apply the day offset, then add the hours. It could resolve your problem!
This situation is common! The GUI displays the expiration date at the end of the given day. So, when you set `1/24/2026 12:00:00 AM`, it’s interpreted as the start of the day on January 24, effectively meaning the account expires at the end of January 23. To ensure the account is active throughout January 24, you should set the expiration to `1/25/2026 12:00:00 AM`. That change will have it show correctly as January 24 in the GUI.
It's one of those tricky time zone and end-of-day definitions! I recommend checking out some documentation on account expiration dates. It might shed light on how different systems handle the cutoff. Here are a couple of links that could help: [Delinea Help](https://docs.delinea.com/online-help/account-lifecycle-manager/alm-objects/account-exp-dates.htm) and [R.L. Mueller's Guide](https://www.rlmueller.net/AccountExpires.htm). They cover some of the nuances quite well.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically