-
Notifications
You must be signed in to change notification settings - Fork 1
/
Move-SBUsers.ps1
24 lines (19 loc) · 903 Bytes
/
Move-SBUsers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# add pit nyn alb phi
$OUs = @(
'OU=Users,OU=New Jersey,OU=North East,OU=Offices,DC=tcco,DC=org'
'OU=Users,OU=Albany,OU=North East,OU=Offices,DC=tcco,DC=org'
'OU=Users,OU=Buffalo,OU=North East,OU=Offices,DC=tcco,DC=org'
'OU=Users,OU=Philadelphia,OU=North Central,OU=Offices,DC=tcco,DC=org'
'OU=Users,OU=Pittsburgh,OU=North Central,OU=Offices,DC=tcco,DC=org'
)
$Target = 'OU=Users,OU=Mahwah,OU=North East,OU=Offices,DC=tcco,DC=org'
ForEach($OU in $OUs){
"Running for $OU"
$SBUsers = Get-aduser -SearchBase $OU -Filter {streetaddress -like "*3 Paragon*"}
"Found $($SBusers.count)"
ForEach($SBUser in $SBUsers){
Move-ADObject -Identity $SBUser.DistinguishedName -TargetPath $Target
Write-host "Moving $($SBuser.DisplayName) to $Target" -ForegroundColor Green
}
Write-host "Moved $($SBusers.count) Users from $OU" -ForegroundColor Green
}