这个脚本今天在测试时运行得很好。我做了一些更改并开始出错。然后我回到了我从互联网上获得的原始剧本,现在即使它不起作用。错误是:
Exception calling "SetInfo" with "0" argument(s): "A constraint violation occurred." At C:\Scripts\CreateTest2.ps1:51 char:2 + $LABUser.SetInfo() + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI Exception calling "Invoke" with "2" argument(s): "There is no such object on the server." At C:\Scripts\CreateTest2.ps1:55 char:2 + $LABUser.psbase.invoke("setPassword", $Pwrd) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodTargetInvocation Exception calling "InvokeSet" with "2" argument(s): "The directory property cannot be found in the cache" At C:\Scripts\CreateTest2.ps1:56 char:2 + $LABUser.psbase.invokeSet("AccountDisabled", $false) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodTargetInvocation Exception calling "CommitChanges" with "0" argument(s): "A constraint violation occurred." At C:\Scripts\CreateTest2.ps1:57 char:2 + $LABUser.psbase.CommitChanges() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
这是脚本。我做错了什么?
ToString(string format)
答案 0 :(得分:-1)
您可以尝试从
中删除引号1)LABUser赋值,即CN = $ CN。
2)从那条线上移除CN =。
逐一尝试,希望你得到答案。