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

Authentication Failed in Microsoft Flow

The Default Mailbox size for Exchange Online E3 and E5 users is increasing from 50GB to 100GB

The Default Mailbox size for Exchange Online E3 and E5 users is increasing from 50GB to 100GB

Road Map to Microsoft Exchange 2019

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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • 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
  • Customizable Recipient Limits in Office 365
  • New Office Apps for Everyone!!!
Aerrow Copyright © 2022.
Theme by MyThemeShop. Back to Top ↑