ivan belarus
ivan belarus

Reputation: 23

passing parameters from command line to powershell

When I run the following command in command line

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

I get the error below:

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

Upvotes: 2

Views: 1470

Answers (1)

manojlds
manojlds

Reputation: 301547

Try this:

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

Upvotes: 2

Related Questions