Powershell command to add AD members to group from CSV file

I'm trying to add users to specific groups based on a CSV file that is imported into Powershell.  The import works fine but I've tried using the add-adgroupmember cmdlet and then the add-adprincipalgroupmembership cmdlet, both are bombing out.  The column in the CSV file is titled "Name" so this is what I'm doing
Import-Csv .\FileName.csv [then I press return]  Next is:
foreach ($user in $Staff) {add-adgroupmember -Identity GroupName -Member $_.Name} (also tried $Staff.Name -both give the same error)

I've attached a file with the error  I have only 1 space between the -Member and $_.Name attributes.  The error places the <<<< in between.  Any help will be apprciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First off, you're neither setting Import-Csv to a variable, nor do you pass it down the pipeline to other commands.
Then you're using the ForEach statement, not the ForEach-Object cmdlet, so in the loop, you'd need to use $User.Name instead of $_.Name.
So either use this:
$Staff = Import-Csv .\FileName.csv
foreach ($user in $Staff) {add-adgroupmember -Identity GroupName -Member $user.Name}

Open in new window

Or this:
Import-Csv .\FileName.csv | ForEach-Object {add-adgroupmember -Identity GroupName -Member $_.Name}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
skbarnardAuthor Commented:
It has been awhile since I asked this question but oBdA pointed out my short-coming with my for-each iteration.  I used the first of the 2 suggestions and got it to work for me.
Sorry for the long delay in my response, we've just been very slammed here at work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.