Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Bulkadd Users to Group - deep level ou

$
0
0

Hi.

I am trying to bulk-add users in a txt-file to a group. However both users and group are placed in a sub-ou so when I run my script the group and users cannot be found.

Also - I would like the user to be prompted for path of the file, but putting $path and $file together with the possibility of mistakes regarding "spaces" and "backslash" prevented me for trying.

If you did not think it already I am adding a wishlist now: If the result of persons added to the group could be listed on the screen it would be perfect.

Here's my "no good"-script:

 

Import-Module ActiveDirectory

 

# Ask the user to enter a filename

$filename = Read-Host "Name of Your txt-file - type 'c:\Users\xxx\documents\navne.txt'"

# Ask the user to enter a groupname

$groupname = Read-Host "Name of Your Group"

 

$users = Get-Content $filename

 

Add-ADGroupMember -Identity $groupname -Members $users

Regards

Carsten


Viewing all articles
Browse latest Browse all 8583

Trending Articles