powershell - 将参数从命令行传递到 powershell

标签 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

最佳答案

试试这个:

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

关于powershell - 将参数从命令行传递到 powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15760145/

相关文章:

command-line - 使用批处理和VBS创建快捷方式

macos - 上传注释到文件元数据 "Get Info"Mac 命令行

linux - Bash:我如何从文件中选择列中具有特定值的行

iis - 为什么/如何在获取和设置时 ManagedPipelineMode 是不同的类型?

powershell - 如何向 PowerShell PSDrive "function:"上的函数对象添加属性?

powershell - Get-ChildItem传递Powershell中的Where-Object失败?

powershell - 从文件导入脚本 block

MySQL命令行和事务

Linux 命令行 : id, 组和 getent 组返回的结果不一样

Powershell 将空字符串视为相当于 switch 语句中的 null 而不是 if 语句