sirichaiphumirat
asked on
Exchange 2010 Powershell Script to create distribution list
Hello Totally New at the scripting. But i'm trying to make a script so our help desk can create distro group with emails without having to connect to the exchange server it self, and only having them use a powershell script. Below is the script that i came up with, but having a bit of an issue trying to get it to work. As i am not sure how i can get return the switch result in to a variable.
This is exchange 2010. Thanks for helping out in advance.
$DistributionGoup = Read-Host -Prompt 'New Distribution Group Name ( No Spaces)'
$Alias = Read-Host -Prompt 'Enter Alias Name'
Write-Host Please Pick The Domain From The Following List
Write-Host 1. CB Domain
Write-Host 2. TB Domain
Write-Host 3. PS Domain
Write-Host 4. GB Domain
Write-Host 5. TC Domain
$domain = Read-Host -Prompt "Domain"
switch ($domain)
{
1 {"cb.smbmi.local/distribut ion Groups";break}
2 {"tb.smbmi.local/distribut ion Lists";break}
3 {"ps.smbmi.local/distribut ion Groups";break}
4 {"gb.smbmi.local/distribut ion Groups";break}
5 {"tc.smbmi.local/distribut ion Groups";break}
default {"No Domain Determined."}
}
new-DistributionGroup -Name $DistributionGoup -OrganizationalUnit $domain -SamAccountName $DistributionGoup -Alias $DistributionGoup
This is exchange 2010. Thanks for helping out in advance.
$DistributionGoup = Read-Host -Prompt 'New Distribution Group Name ( No Spaces)'
$Alias = Read-Host -Prompt 'Enter Alias Name'
Write-Host Please Pick The Domain From The Following List
Write-Host 1. CB Domain
Write-Host 2. TB Domain
Write-Host 3. PS Domain
Write-Host 4. GB Domain
Write-Host 5. TC Domain
$domain = Read-Host -Prompt "Domain"
switch ($domain)
{
1 {"cb.smbmi.local/distribut
2 {"tb.smbmi.local/distribut
3 {"ps.smbmi.local/distribut
4 {"gb.smbmi.local/distribut
5 {"tc.smbmi.local/distribut
default {"No Domain Determined."}
}
new-DistributionGroup -Name $DistributionGoup -OrganizationalUnit $domain -SamAccountName $DistributionGoup -Alias $DistributionGoup
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry quick question, how can i add spaces within the variable. For the example above. distribution groups has a space in them.
Enclose the name in double quotes
Eg. "Group name with space"
Thanks
Eg. "Group name with space"
Thanks
ASKER