Powershell set account expiration date

Notice that in Active Directory Users and Computers (ADUC) as soon as establishing the expiration of a user account, there’s only a means to have the account expire at the end of a particular day:

*

The very same choice exists in the Active Directory Administrative Center (ADAC):

*

In ADAC, you can see the PowerShell command that the GUI supplies to achieve this task:

*

Let’s query that specific residential property through PowerShell to view exactly what it’s currently set to:




You watching: Powershell set account expiration date

Get-ADUser -Identity alan0 -Properties AccountExpirationDate |Select-Object -Property SamAccountName, AccountExpirationDate

*

Notice in the previous outcomes, that there’s not only a day, yet a time too.

Using PowerShell, I’ll set the AccountExpirationDate to the certain date and time when I desire the account to expire:




See more: How To Troubleshoot An Acomdata External Hard Drive Not Recognized

*

Now I’ll double check the worth of what that certain property is set to again:




See more: Cannot Complete The Compressed (Zipped) Folders Extraction Wizard Windows 10

Get-ADUser -Identity alan0 -Properties AccountExpirationDate |Select-Object -Property SamAccountName, AccountExpirationDate

*

One thing I noticed is that when the day and time collection for the account to expire was reached, the user was prevented from logging right into a pc, yet it took a while prior to they were prevented from logging right into Outlook Net Access. Just somepoint to keep in mind