Solved

importing users to Security group

Posted on 2016-11-02
2
66 Views
Last Modified: 2016-11-02
Dear experts
could you please help me with this one?

I have a security group that I exported users via PowerShell to a csv file and  I now need to import those users into a new Universal security group but I am receiving  an error from PowerShell during import process.

this is the full code I used.

Import-Module ActiveDirectory
$list =import-csv "H:\temp\export\usg_users.csv
foreach ($user in $list) {
add-ADGroupMember -identity USG-Security GroupNAme -member $user.SamAccountname
}
error is
Add-ADgroupmember: A positional parameter cannot be found that accepts argument "GroupNAme"

there is a - and  space in the actual security group name in AD. so name is written such as USG-Customer Services

any ideas why I am receiving this please? thanks.
0
Comment
Question by:kuzum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 41870076
You need to enclose the group name in quotes.
Add-ADGroupMember -Identity 'USG-Security GroupName' -Member $user.SamAccountname

Open in new window

0
 

Author Closing Comment

by:kuzum
ID: 41870121
Hi,

I used " " and it also did the worked just after posting the question. Thanks for your time.
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question