$allWin10_OUs=Get-ADOrganizationalUnit -Filter 'Name -like "*Win10*"' -Properties DistinguishedName | Select DistinguishedName
#desktops
foreach ($a in $allWin10_OUs) {
[string]$sOU = $a
$sourceDesktopOU = "OU=Desktop," + ($sOU.TrimStart("@{DistinguishedName=")).trimend("}")
$targetDesktopOU = $sourceDesktopOU.Replace("Win10","Win11")
Get-ADComputer -Properties DistinguishedName, OperatingSystemVersion -Filter 'OperatingSystemVersion -eq "10.0 (22631)"' -SearchBase $sourceDesktopOU | Move-ADObject -TargetPath $targetDesktopOU
}
#mobiles
foreach ($a in $allWin10_OUs) {
[string]$sOU = $a
$sourceMobileOU = "OU=Mobile," + ($sOU.TrimStart("@{DistinguishedName=")).trimend("}")
$targetMobileOU = $sourceMobileOU.Replace("Win10","Win11")
Get-ADComputer -Properties DistinguishedName, OperatingSystemVersion -Filter 'OperatingSystemVersion -eq "10.0 (22631)"' -SearchBase $sourceMobileOU | Move-ADObject -TargetPath $targetMobileOU
}
Brak komentarzy:
Prześlij komentarz