Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Set-ADUser InvalidArgument exception when using variable in parameter

$
0
0

Hi,

I try to use the following commands to Set-ADUser:

$yPropertyName = "GivenName"

set-aduser Di.Wu -$yPropertyName Didi

but I get the error:

Set-ADUser : A positional parameter cannot be found that accepts argument '-GivenName'.
At line:1 char:11
+ set-aduser <<<<  Di.Wu -$yPropertyName Di
    + CategoryInfo          : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser

I try to use this code in a function, so I can pass in property name and value to update the AD user. Please help.

Thanks,

Yong


Viewing all articles
Browse latest Browse all 8583

Trending Articles