我试图编写一个创建2个组的脚本,immediatley将它们移动到(已经存在的)OU。
我尝试检查可能的答案,但这不应该太难。但是,我设法相处的代码似乎不起作用:
New-ADGroup -Name "Soccer players" -GroupScope Global
New-ADGroup -Name "Tennis players" -GroupScope Global
Get-ADGroupMember "Soccer players" -Recursive | Move-ADObject –TargetPath "OU=SportGroups,DC=funsports,DC=local"
Get-ADGroupMember "Tennis players" -Recursive | Move-ADObject –TargetPath "OU=SportGroups,DC=funsports,DC=local"
创建组但未移至OU
我尝试过使用引号(在ADGroupMember和目标中)的变体,...但它似乎永远不会起作用....
我的问题在哪里?
更新
New-ADGroup -Name "Soccer players" -GroupScope Global –Path "OU=SportGroups,DC=funsports,DC=local"
New-ADGroup -Name "Tennis players" -GroupScope Global –Path "OU=SportGroups,DC=funsports,DC=local"
创建组但不在SportGroups OU中(但在默认的'用户'容器中)
答案 0 :(得分:2)
您可能希望移动组而不是其成员:
$ou = 'OU=SportGroups,DC=funsports,DC=local'
Get-ADGroup 'Soccer players' | Move-ADObject –TargetPath $ou
或者您可以在创建时将组放置在正确的OU中,因此您不需要在第一时间移动它们:
$ou = 'OU=SportGroups,DC=funsports,DC=local'
New-ADGroup -Name 'Soccer players' -Path $ou -GroupScope Global