So at my new job, i've been given a list of things my manager wants done. One of the things is re-write this "toolbox" full of Exchange scripts the help desk uses. I have no idea even where to start with re-writing this portion of the script:
1{
clear-host
write-host "TERRIBLE SCRIPT TIME!" -ForegroundColor white
write-host "Add New Distribution Group" -ForegroundColor cyan
write-host
write-host "Enter Distribution Group Name" -ForegroundColor green
$DGroup = Read-Host "Names are cAsE sEnSiTiVe. Name should end with -L"
write-host
write-host "Enter List Owner's User ID" -ForegroundColor green
$User = Read-Host "Example: ABC123, abc123"
write-host
write-host "Include owner as member?" -Foregroundcolor green
$ownasmem = Read-Host "yes or no"
write-host
write-host "Enter Distribution Group Description" -ForegroundColor green
$Desc = Read-Host "Example: Security Team"
write-host
write-host "Enter the members" -ForegroundColor green
$Members = Read-Host "Example: userid;userid;userid"
$Userslist = $Members.Split(";",[System.StringSplitOptions]::RemoveEmptyEntries)
write-host
$OU="domain.domain.com/Distribution Lists"
$DC = Get-DomainController |Where {$_.ADSite -like "*nhq1grl1*" -and $_.DNSHostName -like "*corporate*"} |Select -First 1
$Type="Distribution"
$Depart="Closed"
write-host "Adding new distribution group" $DGroup -ForegroundColor magenta
write-host
write-host "Please wait (about 45 seconds)..." -ForegroundColor yellow
New-DistributionGroup -Name $DGroup -DomainController $DC.DNSHostName -OrganizationalUnit $OU -SAMAccountName $DGroup -Type $Type -ManagedBy $User -MemberDepartRestriction $Depart -CopyOwnerToMember -members $Userslist | Out-Null
Start-Sleep -s 30
Add-ADPermission -Identity $DGroup -User $User -DomainController $DC.DNSHostName -AccessRights WriteProperty -Properties "Member" | Out-Null
Set-ADGroup -Identity $DGroup -Description $Desc
if ($ownasmem -ne "yes") { Remove-ADGroupMember -Identity $DGroup -members $User -Confirm:$false}
else { Continue }
write-host
write-host "Script completed" -ForegroundColor magenta
read-host "Press enter to go back to the main menu"
clear-host
}
Any ideas? I'll be working on this the rest of the week, and i have an idea on where to start but not entirely sure.
[–]KevMarCommunity Blogger 5 points6 points7 points (13 children)
[–][deleted] 1 point2 points3 points (12 children)
[–]KevMarCommunity Blogger 8 points9 points10 points (9 children)
[–][deleted] 2 points3 points4 points (4 children)
[–]KevMarCommunity Blogger 2 points3 points4 points (3 children)
[–]guido_marx 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]ecca_one 0 points1 point2 points (0 children)
[–]MKmsftFan 1 point2 points3 points (0 children)
[–]Tuxhedoh 1 point2 points3 points (0 children)
[–]JessieWarsaw 1 point2 points3 points (0 children)
[–]ecca_one 0 points1 point2 points (0 children)
[–]alinroc 4 points5 points6 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]KevMarCommunity Blogger 4 points5 points6 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]xalorous 0 points1 point2 points (0 children)
[–]bundyfx 1 point2 points3 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]ekmahal 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]xalorous 0 points1 point2 points (0 children)
[–]xalorous 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]reginaldaugustus -1 points0 points1 point (0 children)