Clear the expiration date for an Active Directory account.

      Clear-ADAccountExpiration [-Identity] ADAccount
        [-AuthType {Negotiate | Basic}] [-Credential PSCredential]
           [-Partition string] [-PassThru] [-Server string]
               [-Confirm] [-WhatIf] [CommonParameters]

   -AuthType {Negotiate | Basic}
       The authentication method to use: Negotiate (or 0), Basic (or 1)
       A Secure Sockets Layer (SSL) connection is required for Basic authentication.

   -Credential PSCredential
       A user account that has permission to perform this action.
       The default is the current user unless the cmdlet is run from an AD PowerShell provider drive
       in which case the account associated with the drive is the default.

       "User64" or "Domain01\User64" or a PSCredential object.

   -Identity ADAccount
       Specify an AD domain object by providing one of the following values.
       (The identifier in parentheses is the LDAP provider name for the attribute.)

          Distinguished Name 
            Example: DC=Helvetia,DC=corp,DC=SS64,DC=com 
          GUID (objectGUID) 
            Example: 599c4d2e-f72d-4d20-8a78-030d69495f20
          Security Identifier (objectSid) 
            Example: S-1-5-21-5165297888-301467370-576410423-1803
          Security Accounts Manager (SAM) Account Name (sAMAccountName)
            Example: Helvetia

       The cmdlet searches the default naming context or partition to find the object.
       If two or more objects are found, the cmdlet returns a non-terminating error.

       This parameter can also get this object through the pipeline or you can set this
       parameter to an object instance.

   -Partition string
       The distinguished name of an AD partition.
       The distinguished name must be one of the naming contexts on the current
       directory server. The cmdlet searches this partition to find the object defined by
       the -Identity parameter. 
       The following two examples show how to specify a value for this parameter.
          -Partition "CN=Configuration,DC=Europe,DC=Test,DC=SS64,DC=com"
          -Partition "CN=Schema,CN=Configuration,DC=Europe,DC=Test,DC=SS64,DC=com"
       In many cases, a default value will be used for the Partition parameter if no value
       is specified.

       Return the new or modified object.
       By default (i.e. if -PassThru is not specified), this cmdlet does not generate any output.

   -Server string
       The AD Domain Services instance to connect to, this may be a Fully qualified domain name,
       NetBIOS name, Fully qualified directory server name (with or without port number) or AD Snapshot instance.

       Examples:  demo

       Prompt for confirmation before executing the command.

       Describe what would happen if you executed the command, without actually executing the command.

Clear-ADAccountExpiration clears the expiration date for an Active Directory user or computer account. When the expiry date for an account is cleared, the account does not expire. The -Identity parameter specifies the user or computer account to modify.


Clear the account expiration date for the user with SamAccountName: TommyEllis:

PS C:\> Clear-ADAccountExpiration -Identity TommyEllis

Clear the account expiration date for the user with DistinguishedName: "CN=TommyEllis,DC=AppNC" on the AD LDS instance: "SS64SVR1:60000"

PS C:\> Clear-ADAccountExpiration -Identity "CN=TommyEllis,DC=AppNC" -server "SS64SVR1:60000"

“Your vision will become clear only when you look into your heart. Who looks outside, dreams. Who looks inside, awakens” ~ Carl Gustav Jung

Related PowerShell Cmdlets

Set-adAccountExpiration - Set the expiration date for an AD account.

Copyright © 1999-2023
Some rights reserved