PowerShell and AD show different user expiration date

active-directorypowershellwindows-server-2012

After running:

Set-ADUser username -AccountExpirationDate "05/18/2017 7:00:00 PM"
Get-ADUser username -Properties AccountExpirationDate

I get this in PowerShell: AccountExpirationDate: 5/18/2017 7:00:00 PM

But user properties shows that the account expires on 5/17/2017.

What causes this?

PowerShell Output

AD Property Settings

Best Answer

Take a test user, and use the MMC GUI to set an account expiraton. Then use Get-adUser to look at the value that is set.When you make GUI choice of 5/19/2017 the Get-Aduser returns 5/20/2017 12:00:00 AM

Notice how the GUI says "End Of" and does not give you a time choice, only date. The "End of" day X here is 0 hundred hours of the next day. Also, date/time properties in AD are always UTC times, and GUI tends to adjust for local time zone offset. https://msdn.microsoft.com/en-us/library/ms675098(v=vs.85).aspx

You can calculate the equivalent GUI choice in powershell with

((get-date "5/19/2017").addDays(1)).toUniversalTime()