question

ChadEyo-3773 avatar image
0 Votes"
ChadEyo-3773 asked ChadEyo-3773 published

How to set one manager for multiple users in AD using a csv file?

Here is the script

"Import-Csv C:\temp\Manager.csv | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}"

This is the error messages I receive after running above script

"Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser


Set-ADUser : A positional parameter cannot be found that accepts argument ''.
At line:1 char:43
+ ... v | foreach {Set-ADUser -Identity $user.user -Manager $User.Manager}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Managem
ent.Commands.SetADUser"

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ChadEyo-3773 commented

Your script is incorrect. There's no "$user" variable.

Try this instead:

 Import-Csv C:\temp\Manager.csv | ForEach-Object {Set-ADUser -Identity $_.user -Manager $_.Manager}

Also, your script uses the "user" property but the error messages you posted show that it's really the "SamAccountName" that was used when you ran the script.

And the error implies that there's more data in the Set-ADUser cmdlet following (or preceding) your named parameters. There's only one positional parameter accepted by the Set-ADUser cmdlet: Identity.

"Set-ADUser : A positional parameter cannot be found that accepts argument ''.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Your script worked. Thank you!

0 Votes 0 ·
IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

Hi,

Please check if there are any non-printable characters in your script.

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.