First off, I’m a complete idiot when it comes to PowerShell/coding in general, so apologies if this is an overly simple question I’m asking.
I’ve got a script that I’m using to create distribution lists in exchange via PowerShell:
param($name,$user=$(throw "You must specify the name of the group"))
New-DistributionGroup -Name $name -OrganizationalUnit "XXX.com/Distribution Lists"
Add-DistributionGroupMember -Identity "$name" -Member "$user"
The first variable, $name, is the name of the group, and the second, $user, is the name of the user to add to the group.
Ideally I’d like to loop the adding of users so someone could evoke the script using ./script GROUPNAME User1 User2 User3 User4 User5.
Could anyone shed any insight or point me in the right direction?
You can treat
$user, or rather$users, as an array:(there might be better ways of adding multiple users, but the above should get you started.)
The script can be called like: