• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 88
  • Last Modified:

importing users to Security group

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
kuzum
Asked:
kuzum
1 Solution
 
oBdACommented:
You need to enclose the group name in quotes.
Add-ADGroupMember -Identity 'USG-Security GroupName' -Member $user.SamAccountname

Open in new window

0
 
kuzumAuthor Commented:
Hi,

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

Featured Post

SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now