使用VBscript将计算机移动到新OU时出现错误80005000 [英] Error 80005000 when moving computer to new OU with VBscript
问题描述
这是我脚本的输出:
Leave SECRETARY in Admin
New OU is LDAP://OU=Technology,OU=DomainComputers,DC=xxx,DC=d2g,DC=com
dest DN is OU=Technology,OU=DomainComputers,DC=xxx,DC=d2g,DC=com
from DN is CN=STUDENT100,OU=Private,OU=DomainComputers,DC=xxx,DC=d2g,DC=com
Move STUDENT100 from Private to Technology
error 80005000
Leave LAP6514H in Kiosk
Leave LAP6461H in Teachers
这是令人反感的代码.这是在一个循环中,该循环从新目的地的数据库中读取ou1,从AD中为相应的计算机读取ou2.
And here's the offending code. This is inside a loop which reads ou1 from a database of new destinations, ou2 is read from AD for the corresponding computer.
If ou1="" Then
wscript.echo "Leave",computername,"in",ou2
Else
If ou1<>ou2 Then
'move to right OU
newOU = "LDAP://OU=" & ou1 & ",OU=DomainComputers," & DCsuffix
wscript.echo "New OU is",newOU
Set objOU = GetObject(newOU)
wscript.echo "dest DN is",objOU.DistinguishedName
wscript.echo "from DN is",PCDN
Wscript.echo "Move",computername,"from",ou2,"to",ou1
On Error Resume next
objOU.MoveHere PCDN, vbNullString
If err.number<>0 then wscript.echo "error",Hex(err.number)
On Error GoTo 0
Set objOU = Nothing
End If
End If
在同一脚本中的其他地方,我有几乎相同的代码,可通过obj.MoveHere将用户成功移至新的OU
I have almost identical code elsewhere in the same script which moves users to new OUs successfully with obj.MoveHere
我已经使用ADSI编辑来检查OU是否正确,并且输出显示新的OU存在.我已经检查了容器的权限.我可以使用"AD用户和计算机" MMC来移动计算机.我在Win2012 R2 DC上以管理员身份运行脚本.我尝试了另一个DC.如果删除出错时恢复",它将显示文本"Active Directory:传递了无效的目录路径名"并停止.有人可以发现我的错误吗?
I have used ADSI edit to check the OUs are right, and the output shows that the new ou exists. I have checked permissions on the containers. I can move the computers with the AD Users and Computers MMC. I run the script as administrator on a Win2012 R2 DC. I tried the other DC. If I remove the 'On Error resume' it shows the text "Active Directory: An invalid directory pathname was passed" and stops. Can someone spot my error please?
3月2日:我用尽了所有尝试的方法.作为一种解决方法,我使用脚本(带有发生错误" ...)来查看需要移动的内容,然后使用AD MMC手动移动它们.我希望能得到一个更好的建议.也许还有另一种不使用LDAP来移动AD对象的方法吗?
2 Mar: I have run out of things to try. As a workaround, I use the script (with the On Error...) to see what needs moving, then use the AD MMC to move them manually. I'd appreciate a better suggestion. Is there perhaps another way to move an AD object not using LDAP?
推荐答案
//
// MessageId: E_ADS_BAD_PATHNAME
//
// MessageText:
//
// An invalid directory pathname was passed
//
#define E_ADS_BAD_PATHNAME _HRESULT_TYPEDEF_(0x80005000L)
您的路径错误.
这篇关于使用VBscript将计算机移动到新OU时出现错误80005000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!