Thursday, February 24, 2011

Renaming a User ,Copy a User's Properties

Renaming a User

This topic explains how to use the Active Directory module for Windows PowerShell to rename a user.

Example

The following example demonstrates how to change the relative distinguished name (also known as RDN) of the user Sara Davis to Sara Hettich:
Rename-ADObject 'CN=Sara Davis,OU=Finance,DC=Fabrikam,DC=com' -NewName 'Sara Hettich'

Additional information

For a full explanation of the parameters that you can pass to Rename-ADObject, at the Active Directory module command prompt, type Get-Help Rename-ADObject –detailed, and then press ENTER.

Copy a User's Properties

This topic explains how to use the Active Directory module for Windows PowerShell to copy the properties of one user to another user.

Example

The following example is a sample script that you can use to copy the properties of the user Sara Davis to the user Miles Reid:
$u=Get-ADUser -Identity Sara Davis -Properties *
New-ADUser -Instance $u -SamAccountName Miles Reid
A script is a series of Active Directory module cmdlets. For more information about running Active Directory module scripts see, Running Windows PowerShell Scripts (http://go.microsoft.com/fwlink/?LinkID=119588)

Additional information

You can use the following parameters when you set many of the common values that are associated with creating a new user in Active Directory Domain Services (AD DS):
  • -AccountExpirationDate
  • -AccountNotDelegated
  • -AccountPassword
  • -AllowReversiblePasswordEncryption
  • -CannotChangePassword
  • -ChangePasswordAtLogon
  • -Enabled
  • -PasswordNeverExpires
  • -PasswordNotRequired
  • -SmartcardLogonRequired
  • -TrustedForDelegation

  • -DisplayName
  • -GivenName
  • -Initials
  • -OtherName
  • -Surname
  • -Description

  • -City
  • -Country
  • -POBox
  • -PostalCode
  • -State
  • -StreetAddress

  • -Company
  • -Department
  • -Division
  • -EmployeeID
  • -EmployeeNumber
  • -Manager
  • -Office
  • -Organization
  • -Title

  • -Fax
  • -HomePhone
  • -MobilePhone
  • -OfficePhone

  • -EmailAddress
  • -HomeDirectory
  • -HomeDrive
  • -HomePage
  • -ProfilePath
  • -ScriptPath

  • -Certificates
  • -LogonWorkstations
  • -PermittedLogonTimes
  • -UserPrincipalName
  • -ServicePrincipalNames
In addition to the standard Lightweight Directory Access Protocol (LDAP) attributes, you can retrieve the following extended properties of the Get-ADUser cmdlet by using the -Properties parameter:
  • City
  • Country
  • EmailAddress
  • Fax
  • LogonWorkstations
  • MobilePhone
  • Office
  • OfficePhone
  • Organization
  • OtherName
  • POBox
  • SmartcardLogonRequired
  • State
  • Surname
For a full explanation of the parameters that you can pass to New-ADUser or Get-ADUser, at the Active Directory module command prompt, type Get-Help New-ADUser –detailed or Get-Help Get-ADUser –detailed, and then press ENTER.

No comments:

Post a Comment