Skip to content

Aerrow

Learn to Share, Share to Grow
Menu
  • Home
  • Azure
  • Active Directory
  • Microsoft 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>’

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 ‘

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

Move Bulk AD user from One OU to another using Powershell.

Move Bulk AD user from One OU to another using Powershell.

Application Compatibility avilable for Windows 7

Application Compatibility avilable for Windows 7

[How To]Change Windows 8 Product Key To Complete Activation

[How To]Change Windows 8 Product Key To Complete Activation

About Author

pdhewjau

Prashant is a Principal Cybersecurity Specialist at Thakral One Nepal. His prior position as a Modern Work Security Specialist at Microsoft saw him providing invaluable guidance to major clients in Bangladesh, Brunei, Cambodia, and Myanmar, assisting them with their foundational security needs. Awarded the esteemed Microsoft Most Valuable Professional (MVP) accolade in 2017, Prashant is recognized globally among Microsoft peers. Since 2010, he has imparted his expertise as a Microsoft Certified Trainer (MCT), conducting specialized training across Nepal.

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

  • Unlocking the Power of Message Recall in Outlook Online: A New Era of Email Management
  • A Comprehensive Guide to Identity Governance in Entra ID: Features, Benefits, and Implementation Steps
  • A Comprehensive Guide to Azure Privileged Identity Management (PIM): Features, Benefits, and Implementation Steps
  • Mastering Identity Protection and Risk Detection with Azure AD: Features, Benefits, and Implementation Steps
  • Mastering Conditional Access Policies: The Backbone of Dynamic Security in Azure
  • Multi-Factor Authentication (MFA) with Microsoft Entra ID: Best Practices and Implementation Guide
  • Single Sign-On (SSO) with Microsoft Entra: Best Practices and Step-by-Step Implementation Guide
  • Azure Entra: 10 Key Features to Protect and Govern Your Identities
  • Immutable Hard matching on Azure AD
  • [FIX] : OneDrive Sync Pending for long time
Aerrow Copyright © 2025.
Theme by MyThemeShop. Back to Top ↑