Skip to content

Aerrow

Learn to Share, Share to Grow
Menu
  • Home
  • Azure
  • Active Directory
  • Office 365
  • Exchange
  • Microsoft Teams
November 28, 2016
HomeActive Directory[solved] Expire AD account immediately

[solved] Expire AD account immediately

By pdhewjau Active Directory, Blog  0 Comments

Hey, Hi I am back again with the few tips on Active Directory User Accounts. There are few scenarios that we want to expire the account immediately, or sometime we just want to expire account or Password for testing purpose. In case of the password expire, you cannot do it immediately. Instead you can expire the account and select the option for the ‘User must change password at next logon’, so when you login next time password is expired. if you go to your ‘Active Directory Users and Computers’ to the users property, you will not find any facility to expire the user on desired time or just immediate. If you go with the GUI mode, you need to wait till next day. Here are the properties of the User Account on below snap.

adpe1

Similarly, if you go with the advance panel of the Active Directory user management i.e. ‘Active Directory Administrative Center’ you will still find the same screen you will not have the immediate expire option of the user. For reference below is the snapshot of my user properties as on the Active Directory.

adpe2

Now when I go to the PowerShell, and try to get the detail of the user. Over there I can find exact time when my user is going to get expire. So in CUI mode I can have a specific time to get the account expire. To expire the account on desired time I can use the following command-line.

‘Set-ADAccountExpiration -Identity <UsersamAccountName> -DateTime <desiredDateAndTime>’

PowerShell
1
PS C:\>Set-ADAccountExpiration -Identity Prashant -DateTime '11/18/2016 22:00:00'

adpe3

After the successful command line, you can get the detail of the user when it is going to get expire below is the command line that can help you.

‘Get-ADUser -Identity <UserSamAccountName> -Properties AccountExpirationDate ‘

PowerShell
1
PS C:\>Get-ADUser -Identity Prashant -Properties AccountExpirationDate

adpe4

Now you just need to wait till the time when you have set to expire the Account, it can be 1 minute or 5 or 15. Just wait… your account will get expire.

 

Tags:Account Expire, Active Directory, ADDS, Password Expire, PowerShell, PowerShell Script

Related Posts

[FIXED] Gadget Window disappear in Windows 7

[FIXED] Gadget Window disappear in Windows 7

Configuring Teams Webinar to Everyone

[step by step]Exchange 2016 Installation Requirement

[step by step]Exchange 2016 Installation Requirement

About Author

pdhewjau

Prashant is a Microsoft MVP for Office Servers and Services. He works as Technical Lead on Thakral One and a Microsoft Certified Trainer for Windows Server, Exchange Server and office 365.

Add a Comment

Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Cross-Tenant shared channel communication for Microsoft Teams
  • Bulk Update Use Information in Microsoft 365 using PowerShell
  • Configuring Teams Webinar to Everyone
  • Configuring Teams PowerShell
  • The MVP Challenge- Microsoft 365 Challenge
  • Restrict Guest Access Permission in Azure Active Directory
  • Azure AD My Sign-Ins Activity Report
  • Turn on New Calling and Meeting Experience in MS Teams
  • Microsoft Teams Custom Backgrounds
  • Microsoft Teams Guest Access
Aerrow Copyright © 2023.
Theme by MyThemeShop. Back to Top ↑