将参数从命令行传递给powershell

时间:2013-04-02 09:07:33

标签: powershell command-line

在命令行中运行以下命令时

powershell.exe "Import-Module ActiveDirectory;New-ADUser -name "rr" 
-path "OU=Test,DC=Example,DC=com"

我收到以下错误:

New-ADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
At line:1 char:56
+ Import-Module ActiveDirectory;New-ADUser -name rr -path <<<<  OU=Test,DC=Example,DC=com
    + CategoryInfo          : InvalidArgument: (:) [New-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.NewADUser

1 个答案:

答案 0 :(得分:2)

试试这个:

powershell.exe "Import-Module ActiveDirectory;New-ADUser -name 'rr' `
-path 'OU=Test,DC=Example,DC=com'"
相关问题