Enable-ADAccount

Enable an Active Directory account.

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

Key
   -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
       The user account credentials to use to perform this task.
       The default credentials are those of the currently logged on user unless the
       cmdlet is run from an Active Directory PowerShell provider drive.
       If the cmdlet is run from such a provider drive, the account associated with the drive is the default.

       Type a user name, such as "User64" or "Domain64\User64" or specify a
       PSCredential object such as one generated by Get-Credential 

       If a user name is specified, the cmdlet will prompt for a password.

    -Identity ADAccount
       An Active Directory account object by providing one of the following values.
       (The identifier in parentheses is the LDAP provider name for the attribute.)

          Distinguished Name 
            Example: CN=JonSmith,CN=Sales,OU=europe,CN=users,DC=corp,DC=SS64,DC=com 
          GUID (objectGUID) 
            Example: 599c3d2e-f72d-4d20-8a88-030d99495f20
          Security Identifier (objectSid) 
            Example: S-1-5-21-3165297888-301567370-576410423-1103
          Security Accounts Manager (SAM) Account Name (sAMAccountName)
            Example: JonSmith

       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.

       This example shows how to set the parameter to a distinguished name.
          -Identity  "CN=JonSmith,CN=Sales,OU=europe,CN=users,DC=corp,DC=SS64,DC=com"

       This example shows how to set this parameter to a group object instance named "accountInstance".
          -Identity $accountInstance
             
   -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.  The rules for determining the default value are given below.
       Note that rules listed first are evaluated first and once a default value can be
       determined, no further rules will be evaluated.
        
       In AD DS environments, a default value for Partition will be set in the following cases:
        - If the Identity parameter is set to a distinguished name, the default value of Partition
          is automatically generated from this distinguished name.

        - If running cmdlets from an AD provider drive, the default value of Partition
          is automatically generated from the current path in the drive.

        - If none of the previous cases apply, the default value of Partition will be set to the
          default partition or naming context of the target domain.
        
       In AD LDS environments, a default value for Partition will be set in the following cases: 
        - If the Identity parameter is set to a distinguished name, the default value of Partition
          is automatically generated from this distinguished name. 

        - If running cmdlets from an Active Directory provider drive, the default value of Partition
          is automatically generated from the current path in the drive.

        - If the target AD LDS instance has a default naming context, the default value of Partition
          will be set to the default naming context.

       To specify a default naming context for an AD LDS environment, set the msDS-default NamingContext
       property of the AD directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.
        - If none of the previous cases apply, the Partition parameter will not take any default value.
        
   -PassThru switch
       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)

   -Confirm
       Prompt for confirmation before executing the command.

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

Enable-ADAccount enables an Active Directory user, computer, or service account.

The -Identity parameter specifies the AD user, computer service account, or other service account to be enabled. Identify an account by its distinguished name (DN), GUID, security identifier (SID), or Security Accounts Manager (SAM) account name. Alternatively set the -Identity parameter to an object variable, or pass an account object through the PowerShell pipeline. For example, pipe from Get-ADUser to Enable-Account. Similarly, you can use Get-ADComputer and Search-ADAccount to retrieve account objects.

For AD LDS environments, the -Partition parameter must be specified except in the following two conditions:
-The cmdlet is run from an Active Directory provider drive.
-A default naming context or partition is defined for the AD LDS environment. To specify a default naming context for an AD LDS environment, set the msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.

Examples

Enable an account with SamAccountName: SteveWozniak:

PS C:\> Enable-ADAccount -Identity SteveWozniak

Enable an account using a DistinguishedName:

PS C:\> Enable-ADAccount -Identity "CN=SteveWozniak,OU=RemoteAccounts,DC=SS64,DC=COM"

Enable all accounts in an OU:

PS C:\> Get-ADUser -Filter 'Name -like "*"' -SearchBase "OU=RemoteAccounts,DC=SS64,DC=COM" |
Enable-ADAccount

“Disability is a matter of perception. If you can do just one thing well, you're needed by someone” ~ Martina Navratilova

Related PowerShell Cmdlets

Disable-ADAccount - Disable an Active Directory account.
Search-ADAccount - Get Active Directory user, computer, and service accounts.
Unlock-ADAccount - Unlock an Active Directory account.


 
Copyright © 1999-2024 SS64.com
Some rights reserved