我试图在PHP中使用PowerShell.exe -command $command
,其中该命令是为新用户创建的。从CMD启动Powershell返回“无法将'System.Object []'转换为类型'System.String'”
我注意到它没有运行,并试图直接从CMD
启动它(我相信这就是exec();)。
的代码我试图运行:
powershell.exe -command New-ADUser -SAMAccountName "jajaap" -Instance "Get_ADUser -Identity UserTemplate" -Name "Jan Jaap" -DisplayName "Jan" -Path "OU=Users-NL,OU=Users,OU=Domain-Test,DC=Domain-controller,DC=com" -GivenName "Jan" -Surname "Jaap" -userPrincipalName "[email protected]"
我得到的错误是:
New-ADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
我的猜测是,我要逃跑的路径字符串的某些字符,但我不知道如何,或不知道。或者可能是CMD中有一个converttostring
类型的函数?我无法在Google上找到它。在这里,我看到了一些关于如何修复邮件功能的例子,但我无法弄清楚如何在我的代码中使用这些解决方案。所以请原谅,如果这个问题已经得到解答。
嗨,马克,感谢您的快速帮助。我正在尝试你上面陈述的方式,并得到这个错误:字符串缺少结束符:'。 + CategoryInfo:ParserError:(:) [],ParentContainsErrorRecordException + FullyQualifiedErrorId:TerminatorExpectedAtEndOfString –
您确定在字符串末尾有单引号吗? –
我相信我补充说,我复制了你上面陈述的内容。 –