Share via

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

Chad Eyo 21 Reputation points
2021-06-14T23:47:52.85+00:00

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 for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

  1. Rich Matheisen 48,116 Reputation points
    2021-06-15T02:17:09.03+00:00

    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 additional answer

Sort by: Most helpful
  1. Anonymous
    2021-06-15T01:42:22.593+00:00

    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.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.