Solved

importing users to Security group

Posted on 2016-11-02
2
57 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 84

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 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