我正在尝试编写一个脚本来移动 AD 2008 中的用户 OU
$Alias = "hareeshvm"
# Finding the location of the user account harveesm:
$Root = [ADSI]("LDAP://DC=corp,DC=bharatpetroleum,DC=com")
$searcher = new-object System.DirectoryServices.DirectorySearcher($root)
$searcher.filter = "(&(objectClass=user)(mailNickName= $Alias))"
$User = $searcher.findone()
# Binding the user account to $AUser and the OU to move to to $MovetoOU
$ADSPath = $User.Properties.adspath
$MoveToOU = [ADSI]("LDAP://OU=Temp,DC=corp,DC=bharatpetroleum,DC=com")
$AUser = [ADSI]("$ADSPath")
# 执行实际移动的命令
$AUser.PSBase.moveto($MoveToOU)
我得到下面提到的错误
使用“1”参数调用“MoveTo”的异常:“服务器不愿意处理请求。”在 D:\Ashish\MS Exchange\New User\newuserscreation.ps1:39 char:21 + $AUser.PSBase .moveto <<<< ($MoveToOU) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
提前谢谢