Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: AD location address field population question

$
0
0

EmployeeID is a parameter for Set-ADUser. To set the employee ID, you simply need to invoke Set-ADUser $ADProperties.SamAccountName -EmployeeID someValue. If you want to set an attribute based on another attribute for the same user though, you’ll have to get that user’s information first, then use it during the set. For example:

$user = Get-ADUser $ADProperties.SamAccountName
Set-ADUser $ADProperties.SamAccountName -EmployeeId $user.PersonID

You could optionally do this in a ForEach-Object block as well, like this:

Get-ADUser | ForEach-Object {
    Set-ADUser $_ -EmployeeId $_.PersonID
}

Note that I haven’t run these commands, just typed them in from memory, so they may need tweaking to get them to actually work.

Does that answer your question?


Viewing all articles
Browse latest Browse all 13067

Trending Articles