【问题标题】:passing parameters from command line to powershell从命令行传递参数到powershell
【发布时间】:2013-04-02 09:07:33
【问题描述】:

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

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

【问题讨论】:

    标签: powershell command-line


    【解决方案1】:

    试试这个:

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

    【讨论】:

    • 非常感谢。它做到了。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 2020-05-18
    • 2016-10-26
    • 1970-01-01
    • 1970-01-01
    • 2016-03-25
    • 1970-01-01
    • 2010-11-21
    • 1970-01-01
    相关资源
    最近更新 更多