Why does this fail?

Just trying to set user properties for displayName, Name to values contained in a CSV file. I have encountered this error before and it makes no sense.

Import-Csv names.csv | Foreach { $user = Get-ADUser $_.samaccountname -Prop displayName $dn = $_.displayname if($user.displayname -ne $dn) { Set-ADUser $user -DisplayName $dn } if($user.Name -ne $dn) { Set-ADUser $user -Name $dn } 

This command works so PS can obviously see the property there through the Get-ADUser cmdlet. Why does the Set-ADUser cmdlet fail?

Set-ADUser Username-Name Last First Set-ADUser : A parameter cannot be found that matches parameter name 'Name'. At line:1 char:20 + Set-ADUser Username-Name Last First + ~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser 

submitted by /u/SlothsLoveDoom
[link] [comments]

Leave a Reply