Updating Active Directory User Properties in Active Directory Using Powershell

In Windows Server 2003 R2, using Powershell v2.0, how can I duplicate the functionality of Set-QADUser to update user properties in Active Directory, for example, their phone number and name?

The trick here is, I would like to do this, not depending on Set-QADUser, and I have no way to use Server 2008 cmdlets yet.

Thank.

+3
source share
2 answers

Gathering things from the Internet, I came up with this ...

function Get-ADUser( [string]$samid=$env:username){
     $searcher=New-Object DirectoryServices.DirectorySearcher
     $searcher.Filter="(&(objectcategory=person)(objectclass=user)(sAMAccountname=$samid))"
     $user=$searcher.FindOne()
      if ($user -ne $null ){
          $user.getdirectoryentry()
     }
}

$user = Get-ADUser 'UserName'

# Output all properties
$user.psbase.properties

# Change some properties
$user.title = 'New Title'
$user.telephoneNumber = '5555551212'
$user.SetInfo()

# Output the results
$user.title
$user.telephoneNumber

Additional Information

+6

ADSI PowerShell. vbscript, .

+1

Source: https://habr.com/ru/post/1731019/


All Articles