Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Bulk Set Manager

$
0
0

Hi.

I have this powershell script.

For some reason it will change all other properties but Manager - and I cannot figure out why - any ideas?

My csv contains Manager stated as SamAccountName.

mport-Module Activ*
 $users = $i = $null 
 $users = Get-ADUser -SearchBase "ou=users,dc=domain,dc=com" -filter * -property GivenName,SurName,description,Company,Manager


$Company = “Company”
$GivenName = $user.GivenName
$SurName = $user.SurName
$Description = $user.Description
$Manager = $user.Manager
$office = $User.Office
$Department = $user.Department
$Title = $user.Title

$users = Import-Csv c:\users.csv -Encoding Unicode
$users # dumps users to allow visual inspection
read-host "press Enter to continue or Ctrl+C to abort"
$users | Foreach {Set-ADUser -Identity $_.SamAccountName -Company $Company}
$users | Foreach {Set-ADUser -Identity $_.SamAccountName -GivenName $_.GivenName}
$users | Foreach {Set-ADUser -Identity $_.SamAccountName -SurName $_.SurName}
$users | Foreach {Set-ADUser -Identity $_.SamAccountName -Description $_.Description}
$users | Foreach {Set-ADUser -Identity $_.SamAccountName -Manager $_.Manager}
#$users | Foreach {Set-ADUser -Identity $_.SamAccountName -Office $_.Office}
#$users | Foreach {Set-ADUser -Identity $_.SamAccountName -Department $_.Department}
#$users | Foreach {Set-ADUser -Identity $_.SamAccountName -Title $_.Title}

I would be obliged if someone could help me out.

Regards


Viewing all articles
Browse latest Browse all 6937

Trending Articles