Solved

importing users to Security group

Posted on 2016-11-02
2
50 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
2 Comments
 
LVL 83

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article explains how to install and use the NTBackup utility that comes with Windows Server.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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