Add-ADGroupMember error in -members parameter

I am trying to run a simple PowerShell script which will enable me to add multiple members to a AD group. I have imported the samaccountname of the users from a .csv file to an array using the following command.

$member = Import-Csv -Path c:\file.csv

I have also printed the values of this array to make sure I have the SAMaccountnames correct, the output is something like this:

user
user1
user2

This rray contains some 700 user names.

Then I run the following:

foreach ($user in $member){Add-ADGroupMember -Identity Group_Name -Members $user}

However, I get the following error:

Add-ADGroupMember : Cannot bind parameter 'Members'. Cannot convert value 
"@{User=user1}" to type "Microsoft.ActiveDirectory.Management.ADPrincipal".
Error: "Cannot convert the "@{User=user1}" value of type "System.Management.
Automation.PSCustomObject" to type "Microsoft.ActiveDirectory.Management.
ADPrincipal"."
At line:1 char:77
+ foreach ($user in $member){Add-ADGroupMember -Identity Bastion_usr -Members $use ...
+                                                                             ~~~~
   + CategoryInfo          : InvalidArgument: (:) [Add-ADGroupMember], ParameterBindingException
   + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember

User is the header in the CSV file.

My thought process while writing this script was:

  • Add member[current_value] to Group_Name;
  • increment current value.

My question is Members getting the value of samaccountname as @{user=user1}? If yes then can we remove @{user= from the front of it and } from it's end?

If the previous assumption is wrong then how can we pass the correct value to -Members?