Lab-Setup-1.3 - WordPress.com

advertisement
<#
.SYNOPSIS
Helps to perform a base configuration of an Exchange 2013 lab
environment.
.DESCRIPTION
Assist in setting up a lab environment, from creating mailboxes and
users to setting up DL's
.NOTES
Version
Change Log
: 1.3
: 1.3 - Advanced features added:
More Complicated DLs - Room lists, dynamic,
OU based, custom name list (CSV source file)
Archive Quotas, Journaling, Delegation and
applying retention policies
Wish list
: More complicated Mailboxes - Phone #'s,
locations and addresses, department, company name
: Mobile Device Quarantines
: Complete lab setup - including Exchange prereq,
install, reboots, etc.
: Transport rule creation
: More advanced password
: Create room mailboxes based off of location,
addresses, and make room lists based off this information
: Assign permissions to shared mailboxes and
allow customizable amount of shared mailboxes
Rights Required
: Local admin on server
Sched Task Req'd
: No
Exchange Version
: 2013
Author
: Just A UC Guy [JAUCG]
Email/Blog/Twitter
: ( )
http://justaucguy.wordpress.com/
Dedicated Blog
: http://justaucguy.wordpress.com/
Disclaimer
: You are on your own. This was not written by,
support by, or endorsed by Microsoft.
Info Stolen from
: http://mikepfeiffer.net/2013/04/how-toadd-a-custom-holiday-to-an-exchange-calendar-with-powershell-and-the-ewsmanaged-api/
:
http://blogs.msdn.com/b/dhruvkh/archive/2012/04/06/working-with-tasksusing-exchange-web-services.aspx
: http://gsexdev.blogspot.com/2012/02/ewsmanaged-api-and-powershell-how-to_22.html
.LINK
[TBD]
.EXAMPLE
.\Set-LabSetup-1.3.ps1
.INPUTS
None. You cannot pipe objects to this script.
#>
#Requires -Version 2.0
param(
[parameter(ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false, Mandatory=$false)]
[string] $strFilenameTranscript = $MyInvocation.MyCommand.Name + "
" + (hostname)+ " {0:yyyy-MM-dd hh-mmtt}.log" -f (Get-Date),
[parameter(ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$true, Mandatory=$false)]
[string] $TargetFolder = "c:\Install",
# [string] $TargetFolder = $Env:Temp
[parameter(ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false, Mandatory=$false)]
[bool] $WasInstalled = $false,
[parameter(ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false, Mandatory=$false)]
[bool] $RebootRequired = $false,
[parameter(ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false, Mandatory=$false)]
[string] $opt = "None",
[parameter(ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false, Mandatory=$false)]
[bool] $HasInternetAccess =
([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet)
)
Start-Transcript -path .\$strFilenameTranscript | Out-Null
$error.clear()
Clear-Host
Pushd
# determine if BitsTransfer is already installed
if ((Get-Module BitsTransfer).installed -eq $true){
[bool] $WasInstalled = $true
}else{
[bool] $WasInstalled = $false
}
[string] $menu = @'
******************************************************************
Exchange Server 2013 Lab Setup for Testing
******************************************************************
Please select an option from the list below.
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
Create databases and replicas
Create Mailboxes
Create Distribution Groups
Create Shared Mailboxes
Create Rooms
Populate email
Populate calendars
Populate Tasks
DLP Policy Creation
Create retention Policies
Configure quotas
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
Configure Disclaimer(s)
Transport Rule Creation
Other - other settings
Mobile Devices Policies
OWA Policies
Enabling Archives
Configure Apps
Configure Journaling
Configure Delegation
Configure Archive Quotas
Create Dynamic Distribution Groups
30) Grant impersonation rights
97) Lab cleanup - remove mailboxes, etc.
98) All of the above
99) Exit
Select an option.. [1-99]?
'@
# Database Creation
function create-database {
# Create Databases
$srvcount = (get-mailboxserver).count
$dbcount = (get-mailboxdatabase).count
write-host "Currently there are $srvcount Mailbox Servers with
$dbcount databases."
# New databases will be put on the first server and replicas on
other servers
$newdb = read-host "How many more databases do you want to create?"
$dbloc = read-host "What directory do you want to use for mailbox
database files(i.e. d:\exchange\databases)"
if ((test-path $dbloc) -eq $false) {
write-host ""
write-host "Creating file location for database files." foregroundcolor green
mkdir $dbloc
write-host ""
}
$logloc = read-host "What directory do you want to use for mailbox
database logs (i.e. d:\exchange\logs)"
if ((test-path $logloc) -eq $false) {
write-host ""
write-host "Creating file location for log files." foregroundcolor green
mkdir $logloc
write-host ""
}
$n = 1
while (($n-1) -lt $newdb) {
$dbname = "database"+$n
$edbname = $dbname+".edb"
$edbfilepath = $dbloc+"\"+$edbname
$logpath = $logloc+"\"+$dbname
$server1 = (get-mailboxserver).name
$server = $server1[0]
if ((get-mailboxdatabase $dbname -erroraction
silentlycontinue) -eq $null) {
new-mailboxdatabase -name $dbname -edbfilepath
$edbfilepath -logfolderpath $logpath -server $server
} else {
$dbname = "database"+$n+"a"
$edbname = $dbname+".edb"
$edbfilepath = $dbloc+"\"+$edbname
$logpath = $logloc+"\"+$dbname
new-mailboxdatabase -name $dbname -edbfilepath
$dbloc+"\"+$edbname -logfolderpath $logpath -server $server
}
$n++
}
} # End database and replica creation
# Validate DAG existence
function dag-check {
$DAGExistence = get-databaseavailabilitygroup
if ($DAGExistence -ne $null) {
# Create replicas
$n = 1
$databases = get-mailboxdatabase
foreach ($line in $database) {
$mailserver = get-mailboxserver
while ($n -lt $srvcount) {
$ap = $n+1
$n2 = $n-1
$server = $mailserver[$n2]
add-mailboxdatabasecopy -identity $line.name activationpreference $ap -server $server
}
}
} else {
CLS
write-host "No Database Availability Group (DAG) exists so no
replicas will be created." -foregroundcolor red
}
cls
write-host "Database creation step complete." -foregroundcolor
green
write-host " "
} # End DAG existence check
# Create mailboxes
function create-mailboxes {
# mailboxes will be created in all available databases
$track = 0
$database = (get-mailboxdatabase).name
$password = read-host "Enter password" -AsSecureString
$dbcount = (get-mailboxdatabase).count
$domain = read-host "Enter a domain to be used for SMTP routing"
$source = import-csv c:\temp\names.csv
foreach ($line in $source) {
$first = $line.first
$last = $line.last
$upn = $first+"."+$last+"@"+$domain
$alias =$first+"."+$last
$displayname = $line.first+" "+$line.last
if ((get-mailbox $upn -erroraction silentlycontinue) -eq $null) {
new-mailbox -userprincipalname $upn -alias $alias -database
$database[$track] -displayname $displayname -Firstname $first -lastname
$last -name $alias -password $password
$track++
if ($track -ge $dbcount) {
$track = 0
}
} else {
write-host "There is already a mailbox with the UPN of " nonewline
write-host $upn -foregroundcolor red
}
}
cls
write-host "Mailbox step complete." -foregroundcolor green
write-host " "
} # End of the create-mailboxes function
# Create Distribution Groups
function create-distributiongroups {
$dlcount = read-host "How many distribution groups would you like to
create"
$members = read-host "Do you want to populate the distribution groups
with random members [y or n]"
if ($members -eq "n") {write-host "OK. Blank Distribution groups
will be created."
} else {
write-host "OK. Will populate distribution groups with 1 to 10
members."
}
$alias1 = "DistributionGroup"
$displayname1 = "Distribution Group "
$dlcounter = 1
while ($dlcounter -lt $dlcount) {
$displayname = $displayname1+$dlcounter
$alias = $alias1+$dlcounter
new-distributiongroup -name $displayname -displayname
$displayname -alias $alias -type distribution
$dlcounter++
if ($members -eq "y") {
$mailboxes = get-mailbox
$NumOfMembers = get-random -minimum 1 -maximum 10
while ($NumOfMembers -lt 10) {
$usercount = (get-mailbox).count
$usernum = get-random -minimum 0 -maximum $usercount
$member = $mailboxes[$usernum]
add-distributiongroupmember -identity $alias -member
$member -erroraction silentlycontinue
$numofmembers++
}
}
}
cls
write-host "Distribution Groups step complete." -foregroundcolor
green
write-host " "
} # End of the create-distributiongroups function
# Create Distribution Groups
function create-dynamicdistributiongroups {
$random = read-host "Create random [1] Dynamic Distribution Groups or
[2] create with a CSV file? [1 or 2]"
if ($random -eq 1) {
$dlcount = read-host "How many distribution groups would you like
to create"
$alias1 = "DistributionGroup"
$displayname1 = "Distribution Group "
$dlcounter = 1
while ($dlcounter -lt $dlcount) {
$displayname = $displayname1+$dlcounter
$alias = $alias1+$dlcounter
$orgunit = read-host "Enter the OU for the Dynamic
Distribution Group"
new-dynamicdistributiongroup -name $displayname -displayname
$displayname -alias $alias -RecipientFilter {RecipientType -eq
'UserMailbox'} -OrganizationalUnit $orgunit
$dlcounter++
}
}
if ($random -eq 2) {
$csvfile = read-host "Specify CSV file for creating Dynamic
Distribution Groups"
$csv = import-csv $csvfile
foreach ($line in $csv) {
new-dynamicdistributiongroup -name $line.displayname displayname $line.displayname -alias $line.alias -RecipientFilter
{RecipientType -eq 'UserMailbox'} -OrganizationalUnit $line.orgunit
}
}
write-host "Dynamic Distribution Groups step complete." foregroundcolor green
write-host " "
start-sleep 5
CLS
} # End of the create-dynamicdistributiongroups function
# Create Shared Mailboxes
function create-sharedmailboxes {
# mailboxes will be created in all available databases
$track = 0
$database = (get-mailboxdatabase).name
$password = read-host "Enter password" -AsSecureString
$dbcount = (get-mailboxdatabase).count
$domain = read-host "Enter a domain to be used for SMTP routing"
$source2 = import-csv c:\temp\sharedmailboxes.csv
foreach ($line in $source2) {
$upn = $line.name+"@"+$domain
$alias = $line.name
new-mailbox -userprincipalname $upn -alias $alias -database
$database[$track] -displayname $alias -name $alias -password $password shared
$track++
if ($track -ge $dbcount) {
$track = 0
}
}
cls
write-host "Shared mailboxes step complete." -foregroundcolor green
write-host " "
} # end of the create-sharedmailboxes function
# Create Rooms mailboxes
function create-roommailboxes {
# mailboxes will be created in all available databases
$track = 0
$database = (get-mailboxdatabase).name
$password = read-host "Enter password" -AsSecureString
$dbcount = (get-mailboxdatabase).count
$domain = read-host "Enter a domain to be used for SMTP routing"
$source2 = import-csv c:\temp\roommailboxes.csv
foreach ($line in $source2) {
$upn = $line.name+"@"+$domain
$alias = $line.name
new-mailbox -userprincipalname $upn -alias $alias -database
$database[$track] -displayname $alias -name $alias -password $password room
$track++
if ($track -ge $dbcount) {
$track = 0
}
}
cls
write-host "Room mailboxes step complete." -foregroundcolor green
write-host " "
} # End of the create-sharedmailboxes function
# Populate Mailboxes with Email
function populate-email {
write-host " "
write-host "Gathering valid mailboxes for recipient and/or sender
of test emails." -foregroundcolor yellow
write-host " "
$mailboxes = Get-Mailbox -Filter 'RecipientTypeDetails -eq
"UserMailbox"' -resultsize unlimited
$sendercount = (get-mailbox -resultsize unlimited).count
$copies = read-host "How many test email messages to be sent per
sender"
$transport = (get-transportservice).name
$counter = 0
while ($counter -lt $sendercount) {
$sender = $mailboxes[$counter].primarysmtpaddress
$from = $sender.local+"@"+$sender.domain
$counter2 = $counter+1
$recipient = $mailboxes[$counter].primarysmtpaddress
$to = $recipient.local+"@"+$recipient.domain
$subject = "Populating email from $sender to $recipient"
$body = "This is a test message to help populate email in the
mailboxes on Exchange 2013."
# Need to add an attachment line here --> needs to include the
option to pick an attachment
$msgcount = 0
while ($msgcount -lt $copies) {
send-mailmessage -from $from -to $recipient -subject $subject
-body $body -smtpserver $transport[0]
$msgcount++
}
$left = $sendercount-($counter+1)
write-host " "
write-host "Test emails to $recipient and from $sender are
complete. Only $left more email tests to run." -foregroundcolor green
write-host " "
$counter++
}
write-host "Email population step complete." -foregroundcolor green
write-host " "
start-sleep 10
cls
}
# Create Calendar Entries
function new-calendarevent {
[CmdletBinding(DefaultParametersetName='Identity')]
param(
[Parameter(Position=0, ParameterSetName='Identity')]
$Identity,
[Parameter(Position=1, Mandatory=$true)]
$Subject,
[Parameter(Position=2, Mandatory=$true)]
$Date,
[Parameter(Position=3)]
[Switch]$Impersonate,
[Parameter(Position=4)]
$ExchangeVersion = 'Exchange2013_CU7',
[Parameter(Position=5, ParameterSetName='Pipeline',
ValueFromPipelineByPropertyName=$true)]
$PrimarySmtpAddress,
[Parameter(Position=6)]
[System.Management.Automation.PSCredential]
$Credential,
[Parameter(Position=7)]
$EWSUrl
)
begin {
#Load the EWS Assembly
Add-Type -Path "C:\Program Files\Microsoft\Exchange
Server\V15\Bin\Microsoft.Exchange.WebServices.dll"
}
process {
#Is the identity coming from the pipeline?
if($PsCmdlet.ParameterSetName -eq 'Pipeline') {
$Identity = $PrimarySmtpAddress.ToString()
}
#Create the ExchangeService object
$service = New-Object
Microsoft.Exchange.WebServices.Data.ExchangeService -ArgumentList
([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::$ExchangeVersion)
#If Credential parameter used, set the credentials on the
$service object
if($Credential) {
$service.Credentials = New-Object
Microsoft.Exchange.WebServices.Data.WebCredentials -ArgumentList
$Credential.UserName, $Credential.GetNetworkCredential().Password
}
#If EWSUrl parameter not used, locate the end-point using autoD
if(!$EWSUrl) {
$service.AutodiscoverUrl($Identity, {$true})
}
else {
$service.Url = New-Object System.Uri -ArgumentList $EWSUrl
}
#If Impersonation parameter used, impersonate the user
if($Impersonate) {
$ImpersonatedUserId = New-Object
Microsoft.Exchange.WebServices.Data.ImpersonatedUserId -ArgumentList
([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress),$Id
entity
$service.ImpersonatedUserId = $ImpersonatedUserId
}
#Configure the start and end time for this all day event
$start = (get-date $date)
$end = $start.addhours(24)
#Create and save the appointment
$appointment = New-Object
Microsoft.Exchange.WebServices.Data.Appointment -ArgumentList $service
$appointment.Subject = $Subject
$appointment.Start = $Start
$appointment.End = $End
$appointment.IsAllDayEvent = $true
$appointment.IsReminderSet = $false
$appointment.Categories.Add('Holiday')
$appointment.Location = 'United States'
$appointment.LegacyFreeBusyStatus =
[Microsoft.Exchange.WebServices.Data.LegacyFreeBusyStatus]::Free
$appointment.Save([Microsoft.Exchange.WebServices.Data.SendInvitationsMod
e]::SendToNone)
}
} # End of the new-calendarevent function
# Create Task Entries
function new-task {
[CmdletBinding(DefaultParametersetName='Identity')]
param(
[Parameter(Position=0, ParameterSetName='Identity')]
$Identity,
[Parameter(Position=1, Mandatory=$true)]
$subject,
[Parameter(Position=2, Mandatory=$true)]
$StartDate,
[Parameter(Position=3, Mandatory=$true)]
$EndDate,
[Switch]$Impersonate,
[Parameter(Position=4)]
# UPDATED to Exchange 2013
$ExchangeVersion = 'Exchange2013_SP1',
[Parameter(Position=5, ParameterSetName='Pipeline',
ValueFromPipelineByPropertyName=$true)]
$PrimarySmtpAddress,
[Parameter(Position=6)]
[System.Management.Automation.PSCredential]
$Credential,
[Parameter(Position=7)]
$EWSUrl
)
begin {
#Load the EWS Assembly - UPDATED to Exchange 2013
Add-Type -Path "C:\Program Files\Microsoft\Exchange
Server\V15\Bin\Microsoft.Exchange.WebServices.dll"
}
process {
#Is the identity coming from the pipeline?
if($PsCmdlet.ParameterSetName -eq 'Pipeline') {
$Identity = $PrimarySmtpAddress.ToString()
}
#Create the ExchangeService object
$service = New-Object
Microsoft.Exchange.WebServices.Data.ExchangeService -ArgumentList
([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::$ExchangeVersion)
#If Credential parameter used, set the credentials on the
$service object
if($Credential) {
$service.Credentials = New-Object
Microsoft.Exchange.WebServices.Data.WebCredentials -ArgumentList
$Credential.UserName, $Credential.GetNetworkCredential().Password
}
#If EWSUrl parameter not used, locate the end-point using autoD
if(!$EWSUrl) {
$service.AutodiscoverUrl($Identity, {$true})
}
else {
$service.Url = New-Object System.Uri -ArgumentList $EWSUrl
}
#If Impersonation parameter used, impersonate the user
if($Impersonate) {
$ImpersonatedUserId = New-Object
Microsoft.Exchange.WebServices.Data.ImpersonatedUserId -ArgumentList
([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress),$Id
entity
$service.ImpersonatedUserId = $ImpersonatedUserId
}
#Create and save the task
$task = New-Object Microsoft.Exchange.WebServices.Data.Task ArgumentList $service
$task.Subject = $subject
$task.StartDate = $startdate
$task.DueDate = $enddate
$task.Save([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Tas
ks)
#
([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Notes)
}
} # End of the new-task function
# Import calendar events
function Create-CalendarEvents {
$events = import-csv c:\scripts\calendarevents.csv
$import = read-host "Do you want to import calendar events into all
mailboxes or random mailboxes ['a' or 'r']"
if ($import -eq "a") {
$mailboxes = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).primarysmtpaddress
foreach ($line in $mailboxes) {
$primary = $line.local+"@"+$line.domain
foreach ($line in $events) {
# get-mailbox | new-calendarevent -subject $line.subject
-date $line.date -impersonate
new-calendarevent -identity $primary -subject
$line.subject -date $line.date -impersonate
}
write-host "Calendar entries for $line.displayname have been
added." -foregroundcolor green
}
} else {
$mbxcount = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).count
$range = get-random -minimum 0 -maximum $mbxcount
$counter = 0
$mailbox = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).primarysmtpaddress
while ($counter -lt $range) {
foreach ($line in $events) {
$address = $mailbox[$counter]
$primary = $address.local+"@"+$address.domain
get-mailbox $primary | new-calendarevent -subject
$line.subject -date $line.date -impersonate
}
$counter++
$name = (get-mailbox $primary).displayname
write-host "Calendar entries for $name have been added." foregroundcolor green
}
}
} # End Create Calendar Items Function
# Import Tasks
function Create-Tasks {
$tasks = import-csv c:\scripts\tasks.csv
$import = read-host "Do you want to import calendar events into all
mailboxes or random mailboxes ['a' or 'r']"
if ($import -eq "a") {
$mailboxes = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).primarysmtpaddress
foreach ($line in $mailboxes) {
$primary = $line.local+"@"+$line.domain
foreach ($line2 in $tasks) {
# get-mailbox | new-task -subject $line.subject -date
$line.date -impersonate
new-task -identity $primary -subject $line2.subject startdate $line2.startdate -enddate $line2.enddate -impersonate
}
write-host "Task entries for $line.displayname have been
added." -foregroundcolor green
}
} else {
$mbxcount = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).count
$range = get-random -minimum 0 -maximum $mbxcount
$counter = 0
$mailbox = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).primarysmtpaddress
while ($counter -lt $range) {
foreach ($line in $tasks) {
$address = $mailbox[$counter]
$primary = $address.local+"@"+$address.domain
get-mailbox $primary | new-task -subject $line.subject startdate $line.startdate -enddate $line.enddate -impersonate
}
write-host "Task entries for $primary have been added." foregroundcolor green
$counter++
}
}
} # End Create Tasks Function
# Impersonation Function
function add-impersonation {
$answer = read-host "Does your user account need the impersonation
right before proceeding [y or n]"
if ($answer -eq "y") {
$user = [Environment]::UserName
# Create Management Scope for impersonation
if ((get-managementscope "impersonation") -eq $null) {
New-ManagementScope –Name:Impersonation –
RecipientRestrictionFilter {RecipientType -eq "UserMailbox"}
}
#Assign impersonation to a user
New-ManagementRoleAssignment –Role:ApplicationImpersonation –
User:$user –CustomRecipientWriteScope:Impersonation
} else {
$answer2 = read-host "Does another user account need the
impersonation right before proceeding [y or n]"
if ($answer2 -eq "y") {
$user = read-host "Enter the name of the account that needs
impersonation rights"
# Create Management Scope for impersonation
if ((get-managementscope "impersonation") -eq $null) {
New-ManagementScope –Name:Impersonation –
RecipientRestrictionFilter {RecipientType -eq "UserMailbox"}
}
#Assign impersonation to a user
New-ManagementRoleAssignment –Role:ApplicationImpersonation
–User:$user –CustomRecipientWriteScope:Impersonation
}
}
} # End of add-impersonation
# Quotas Function
function configure-quotas {
write-host "Enter your Quota values:"
$iwq = read-host "Issue Warning Quota [in MB, unlimited]"
if ([string]$iwq -ne "unlimited") {
[string]$iwq = [string]$iwq+" MB"
}
[string]$psq = read-host "Prohibit Send Quota [in MB]"
if ($psq -ne "unlimited") {
[string]$psq = [string]$psq+" MB"
}
[string]$psrq = read-host "Prohibit Send/Receive Quota [in MB]"
if ([string]$psrq -ne "unlimited") {
[string]$psrq = [string]$psrq+" MB"
}
$answer = read-host "Do you want to apply the policies to all users
or random users [a or r]"
if ($answer -eq "a") {
$mailboxes = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).primarysmtpaddress
foreach ($line in $mailboxes) {
$primary = $line.local+"@"+$line.domain
set-mailbox $primary -ProhibitSendQuota $psq ProhibitSendReceiveQuota $psrq -IssueWarningQuota $iwq UseDatabaseQuotaDefaults $false
write-host "The mailbox for $primary has had their quotas
modified as requested:" -foregroundcolor green
get-mailbox $primary | ft ProhibitSendQuota,
ProhibitSendReceiveQuota, IssueWarningQuota, UseDatabaseQuotaDefaults
}
write-host "Quotas configured for all mailboxes as requested."
} else {
$mbxcount = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).count
$range = get-random -minimum 0 -maximum $mbxcount
$counter = 0
$mailbox = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).primarysmtpaddress
while ($counter -lt $range) {
$address = $mailbox[$counter]
$primary = $address.local+"@"+$address.domain
set-mailbox $primary -ProhibitSendQuota $psq ProhibitSendReceiveQuota $psrq -IssueWarningQuota $iwq UseDatabaseQuotaDefaults $false
write-host "The mailbox for $primary has had their quotas
modified as requested:" -foregroundcolor green
get-mailbox $primary | ft ProhibitSendQuota,
ProhibitSendReceiveQuota, IssueWarningQuota, UseDatabaseQuotaDefaults
$counter++
}
write-host "Quotas configured for $range mailboxes as requested."
}
start-sleep 5
} # End of Quotas function
# Check for Old Disclaimers
function Check-OldDisclaimers {
$rulecheck = (Get-TransportRule).ApplyHtmlDisclaimerText
$rulecheck2 = get-transportrule | where {$_.ApplyHtmlDisclaimerText ne $null}
if ($rulecheck -eq $null) {
write-host " "
write-host "There are no disclaimers in place now." foregroundcolor green
write-host " "
} else {
foreach ($line in $rulecheck2) {
write-host " "
write-host "There is a transport rule in place called $line
that is a disclaimer rule." -ForegroundColor Yellow
write-host " "
}
}
} #End of the Check-OldDisclaimers function
# Add New Disclaimers
function Configure-NewDisclaimers {
$name = read-host "Name of the disclaimer rule"
$DisclaimerNameCheck = get-transportrule | where {$_.name -eq $name}
if ($DisclaimerNameCheck -eq $null) {
$text = read-host "Disclaimer text or HTML"
New-TransportRule -FromScope 'NotInOrganization' ApplyHtmlDisclaimerLocation 'Append' -ApplyHtmlDisclaimerText $text ApplyHtmlDisclaimerFallbackAction 'Wrap' -Name $name StopRuleProcessing:$false -Mode 'Enforce' -Comments '
' -RuleErrorAction 'Ignore' -SenderAddressLocation 'Header'
} else {
write-host "There is a rule with the same name." -nonewline
write-host " Please try the option again." -ForegroundColor Red
write-host " "
Configure-NewDisclaimers
}
} # End of the Configure-NewDisclaimers function
# Enable Archives for all or some users
function enable-archives {
$selection = read-host "Do you want to enable archives for all
mailboxes or random mailboxes [a or r]"
$location = read-host "Would you like to create a new mailbox
database for the archive mailboxes [y or n]"
if ($location -eq "n") {
$database = read-host "Which database will the archive mailboxes
be placed in"
}
if ($location -eq "y") {
$srv = ($server[0]).name
write-host "The new archive database will bew placed on $srv."
$directory1 = read-host "Please enter a valid directory to place
the database files"
$directory2 = read-host "Please enter a valid directory to place
the log files"
$archivename = "ArchiveDatabase"
$edb = $directory1+"\"+$archivename+".edb"
$log = $directory2+"\"+$archivename
$server = get-mailboxserver
new-mailboxdatabase -name $archivename -edbfilepath $edb logfolderpath $log -server $srv -erroraction silentlycontinue
}
# Enable the mailboxes to have archive mailboxes
if ($selection -eq "a") {
$mailboxes = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).alias
foreach ($line in $mailboxes) {
enable-mailbox $line -Archive -ArchiveDatabase $database erroraction silentlycontinue
}
$name = (get-mailbox $alias).displayname
write-host "An archive mailbox for $name has been created." foregroundcolor green
} else {
$mbxcount = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).count
$range = get-random -minimum 0 -maximum $mbxcount
$counter = 0
$mailbox = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).alias
while ($counter -lt $range) {
$alias = $mailbox[$counter]
enable-mailbox $alias -Archive -ArchiveDatabase $database
-erroraction silentlycontinue
$counter++
}
$name = (get-mailbox $alias).displayname
write-host "All archive mailboxes have been created." foregroundcolor green
}
} # End function for archive mailboxes
# Configuring apps forExchange 2013
function configure-Apps {
$option = read-host "Do you want to configure Apps (1) or add new
Apps (2)"
# Prep Random mailboxes (version 1)
$mbxcount = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).count
$range = get-random -minimum 0 -maximum $mbxcount
$mailbox = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).alias
# Create Random User List
$counter = 0
$userlist = @()
while ($counter -lt $range) {
$alias = $mailbox[$counter]
$userlist += @($alias)
$counter++
}
if ($option -eq "1") {
write-host "Currently there are these apps installed in your
Exchange Server 2013 environment"
get-app -OrganizationApp |ft displayname,providedto,userlist auto
$app = (get-app -OrganizationApp).appid
$choice = read-host "Do you want to limit the apps to random
users or allow them for all users [r or a]"
$mailboxes = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).alias
if ($choice -eq "a") {
$name = (get-mailbox $alias).displayname
foreach ($line in $mailboxes) {
foreach ($line in $app) {
set-app $line -OrganizationApp $true -enabled $true
}
}
write-host "Apps have been configured for all users." foregroundcolor green
} else {
foreach ($line in $app) {
Set-App $line -organizationapp -ProvidedTo SpecificUsers
-UserList $userlist
}
}
} else {
# Feature to add later will be user inputed apps - only one app
for now - Message Header Analyzer
# $choice2 = read-host "Install apps from this script (1) or
choose your own apps (2)"
# write-host " "
$choice = read-host "Do you want to limit the apps to random
users or allow them for all users [r or a]"
$Data = get-content -Encoding byte -Path
"c:\scripts\manifest.xml" -ReadCount 0
# foreach ($line in $applist) {
if ($choice -eq "a") {
new-app -DefaultStateForUser Enabled -filedata $data OrganizationApp
} else {
new-app -DefaultStateForUser Enabled -filedata $data OrganizationApp -ProvidedTo SpecificUsers -UserList $userlist
}
#}
}
} # end of the configure-Apps function
# Create Retention Policies
function create-retentionpolices {
$createorapply = read-host "[1] Create or [2] Apply retention
policies [1 or 2]"
if ($createorapply -eq 1) {
$polno = read-host "How many Retention Policies do you want to
create"
$polcounter = 0
while ($polcounter -lt $polno) {
$currentpol = $polcounter +1
$polname = read-host "Specify a name for Rentention Policy number
$currentpol"
$tagno = read-host "How many Retention Tags do you want to
create"
$counter = 0
$alltags = @()
$allpolicies = @()
while ($counter -lt $tagno) {
$current = $counter + 1
$name = read-host "Specify a name for Retention Tag number
$current"
$allpolicies += ,($name)
$time = read-host "Specify a time frame to apply the tag
(i.e. 60, 90, 120)"
$RetentionAction = read-host "Specify a retention action
(DeleteAndAllowRecovery, PermanentlyDelete, MoveToArchive)"
if ($retentionaction -eq "MoveToArchive") {
$type = "all"
} else {
$type = read-host "Specify which folders will be affect
(All, Inbox, etc. )"
}
$comment = read-host "Specify a comment for the Retention Tag
(optional)"
$alltags += ,($name)
if ($retentionaction -eq "permanentlyDelete") {
$archive = $false
} else {
$archive = $true
}
New-RetentionPolicyTag -Name $name -Type $type RetentionAction $retentionaction -RetentionEnabled:$archive AgeLimitForRetention $time -Comment $comment
$counter++
}
new-retentionpolicy -name $polname -RetentionPolicyTagLinks
$alltags
$polcounter++
}
$action = read-host "Do you want to apply these policies to your
users now? [y or n]"
}
# After creating polcies - create them?
if ($action -eq "y") {$createorapply = 2}
if ($createorapply -eq 2) {
$allpolicies = (get-retentionpolicy).name
foreach ($line in $allpolicies) {
$action2 = read-host "For the retention policy $line, do you
want to apply this policy to any users? [y or n]"
if ($action2 -eq "y") {
$applyto = read-host "Do you want to apply the policies
to [a] all users, [r] random users or [c] use a csv file? [a, r or c]"
if ($applyto -eq "a") {
get-mailbox | set-mailbox -retentionpolicy $line
}
if ($applyto -eq "r") {
$mbxcount = (get-mailbox | where
{$_.RecipientTypeDetails -ne "DiscoveryMailbox"}).count
$range = get-random -minimum 0 -maximum $mbxcount
$mailbox = (get-mailbox | where
{$_.RecipientTypeDetails -ne "DiscoveryMailbox"}).alias
$counter = 0
$userlist = @()
while ($counter -lt $range) {
$alias = $mailbox[$counter]
get-mailbox $alias | set-mailbox -retentionpolicy
$line
$counter++
}
}
if ($applyto -eq "c") {
# CSV format is just the mailbox alias, with a header
of 'alias'
$csv = read-host "Specify a CSV file to read from"
foreach ($line in $csv) {
get-mailbox $line.alias | set-mailbox retentionpolicy $line
}
}
}
}
}
} # End of the create-retentionpolices function.
# Create new mobile device policies
function create-mobiledevicepolicy {
write-host " "
write-host "For now, this function will " -nonewline
write-host "only create the password policy portion" -nonewline ForegroundColor red
write-host " of the Mobile Device Policy."
write-host " "
start-sleep 5
write-host "The existing Mobile Device Mailbox Policies are:"
Get-MobileDeviceMailboxPolicy |ft id
$name = read-host "What is the name of the new Mobile Device Mailbox
Policy"
$IsDefault = read-host "Will this policy be the default policy [y or
n]"
if ($isdefault -eq "y") {
$isdefault = $true
} else {
$isdefault = $false
}
$password = read-host "Do you want to create a device password policy
[y or n]"
if ($password -eq "y") {
$AlphanumericPasswordRequired = read-host "Will alphanumeric
passwords be required [y or n]"
if ($AlphanumericPasswordRequired -eq "y") {
$AlphanumericPasswordRequired = $true
}else {
$AlphanumericPasswordRequired = $false
}
$PasswordRecoveryEnabled = read-host "Will password recovery be
enabled [y or n]"
if ($PasswordRecoveryEnabled -eq "y") {
$PasswordRecoveryEnabled = $true
}else {
$PasswordRecoveryEnabled = $false
}
$MaxPasswordFailedAttempts = read-host "How many failed password
attempts [4 through 16 or the value Unlimited]"
$MinPasswordLength = read-host "What is the minimum password
length [1 through 16 or the value $null]"
$complex = read-host "Do you want a complex password policy [y or
n]"
$PasswordHistory = read-host "How many passwords for the device
pasword history [1, 3, 7?]"
if ($complex -eq "y") {
$MinPasswordComplexCharacters = read-host "What will the
minumim complex password characters be allowed [valid range is from 1 to
4]"
New-MobileDeviceMailboxPolicy -name $name -MinPasswordLength
$MinPasswordLength -MaxPasswordFailedAttempts $MaxPasswordFailedAttempts
-PasswordEnabled $true -AlphanumericPasswordRequired
$AlphanumericPasswordRequired -PasswordRecoveryEnabled
$PasswordRecoveryEnabled -MinPasswordComplexCharacters
$MinPasswordComplexCharacters -IsDefault $isdefault -PasswordHistory
$PasswordHistory
} else {
New-MobileDeviceMailboxPolicy -name $name -MinPasswordLength
$MinPasswordLength -MaxPasswordFailedAttempts $MaxPasswordFailedAttempts
-PasswordEnabled $true -AlphanumericPasswordRequired
$AlphanumericPasswordRequired -PasswordRecoveryEnabled
$PasswordRecoveryEnabled -IsDefault $isdefault -PasswordHistory
$PasswordHistory
}
}
if ($password -eq "n") {
New-MobileDeviceMailboxPolicy -name $name
}
} # End of the create-mobiledevicepolicy function
# Create an OWA Policy
function create-OWApolicy {
write-host " "
write-host "For now, this function will " -nonewline
write-host "only create a basic version" -nonewline -ForegroundColor
red
write-host " of the OWA Mailbox Policy."
write-host " "
start-sleep 5
write-host "The existing OWA Mailbox Policies are:"
Get-OWAMailboxPolicy |ft id
$name = read-host "What is the name of the new OWA Mailbox Policy"
$IsDefault = read-host "Will this policy be the default policy [y or
n]"
if ($isdefault -eq "y") {$isdefault = $true} else {$isdefault =
$false}
$AllowOfflineOn = read-host "Do you want to enable OWA offline in
this policy [PrivateComputersOnly | NoComputers | AllComputers]"
$ChangePasswordEnabled = read-host "Would you like their password
change opion to appear [y or n]"
if ($ChangePasswordEnabled -eq "y") {$ChangePasswordEnabled = $true}
else {$ChangePasswordEnabled = $false}
$JunkEmailEnabled = read-host "Enable Junk mail in OWA [y or n]"
if ($JunkEmailEnabled -eq "y") {$JunkEmailEnabled = $true} else
{$JunkEmailEnabled = $false}
$LinkedInEnabled = read-host "Would you like to enable LinkedIn for
OWA [y or n]"
if ($LinkedInEnabled -eq "y") {$LinkedInEnabled = $true} else
{$LinkedInEnabled = $false}
$PublicFoldersEnable = read-host "Enable Public folders in OWA [y or
n]"
if ($PublicFoldersEnable -eq "y") {$PublicFoldersEnable = $true} else
{$PublicFoldersEnable = $false}
$RulesEnabled = read-host "Enable Rules in OWA [y or n]"
if ($RulesEnabled -eq "y") {$RulesEnabled = $true} else
{$RulesEnabled = $false}
write-host " "
write-host "Creating your policy now." -ForegroundColor green
write-host " "
if ($isdefault -eq $true) {
new-OwaMailboxPolicy -name $name
set-OwaMailboxPolicy -isdefault $isdefault -identity $name AllowOfflineOn $AllowOfflineOn -ChangePasswordEnabled
$ChangePasswordEnabled -JunkEmailEnabled $JunkEmailEnabled PublicFoldersEnable $PublicFoldersEnable -RulesEnabled $RulesEnabled
} else {
new-OwaMailboxPolicy -name $name
set-OwaMailboxPolicy -identity $name -AllowOfflineOn
$AllowOfflineOn -ChangePasswordEnabled $ChangePasswordEnabled JunkEmailEnabled $JunkEmailEnabled -PublicFoldersEnable
$PublicFoldersEnable -RulesEnabled $RulesEnabled
}
} # End of the create-OWApolicy function
# Create new Room Lists
Function New-RoomList {
write-host " "
Write-host "This function will help you create rooms and room lists
for your test environment, assuming" -ForegroundColor green
write-host "the OU's and rooms are not created so far." ForegroundColor green
write-host " "
$answer1 = read-host "Create room lists from scratch? [y or n]"
If ($answer1 -eq "y") {
$csvmanual = read-host "Do you want to [1] use a CSV file or
[2] enter the rooms manually ? [1 or 2]"
If ($csvmanual -eq 1) {
# import rooms and room lists from CSV file
# CSV format:
# roomlist,room,ou
$csvfile = read-host "Specify a CSV file to read from"
$csv = Import-csv $csvfile
write-host "No column validation here - use this at your own
risk."
# pausing
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Foreach ($line in $csv) {
# Check for the existence of the Room list, create if it
does not exist
if ((get-distributiongroup $line.roomlist) -eq $null) {
New-DistributionGroup -Name $line.roomlist OrganizationalUnit $line.ou -RoomList
}
$track = 0
$database = (get-mailboxdatabase).name
write-host "For the new Room Mailboxe:"
$mbx = $line.room
$password = read-host "Enter password for the $mbx
mailbox" -AsSecureString
$dbcount = (get-mailboxdatabase).count
$domain = read-host "Enter a domain to be used for the
rooms SMTP address"
#
$source2 = import-csv c:\temp\roommailboxes.csv
$name = $line.room
$name = $name -replace '\s',''
$upn = $name+"@"+$domain
new-mailbox -userprincipalname $upn -alias $name database $database[$track] -displayname $line.room -name $name -password
$password -room
$track++
if ($track -ge $dbcount) {
$track = 0
}
}
# Add members according to the CSV file provided
Add-DistributionGroupMember -Identity $line.roomlist -Member
$line.room
}
If ($csvmanual -eq 2) {
$norooms = read-host "How many rooms do you want to
create?"
$noroomlists = read-host "How many room lists do you
want to create?"
$counter = 0
while ($counter -lt $norooms) {
$roomname = read-host "Enter a name for the room"
$capacity = read-host "Enter a room capacity"
$ou = read-host "Enter an OU to search for [i.e. rooms]"
Get-OrganizationalUnit -SearchText $ou |ft
*canonicalname*
$ou = read-host "Copy one of the OUs above to use for
placing the room mailboxes or enter a new one"
New-mailbox -Name $roomname -OrganizationalUnit $ou -room
-ResourceCapacity $capacity
$counter++
}
$counter = 0
while ($counter -lt $noroomlists) {
$roomlist = read-host "Enter a name for the room list"
$ou2 = read-host "Enter an OU for the room list"
New-DistributionGroup -Name $roomlist -OrganizationalUnit
$ou2 -RoomList
$NoRoomMembers = read-host "How many rooms do you want to
add to the $roomlist roomlist?"
$counter2 = 0
while ($counter -lt $NoRoomMembers) {
$RoomListMember = read-host "What room do you want to
add to the $roomlist room list?"
Add-DistributionGroupMember -Identity $roomlist Member $RoomListMember
$counter2++
}
$counter++
}
}
}
If ($answer1 -eq "n") {
write-host " "
write-host "Exiting room list function...." -foregroundcolor red
write-host " "
start-sleep 5
cls
}
} # End of the New-RoomList function
# Configure Journaling for Exchange
function configure-journaling {
$journaloption = read-host "Do you want to configure [1] Per User
Journaling or [2] Journaling for all messages? [1 or 2]"
# Scope options - Internal | External | Global
$mailbox = read-host "Do you need to create a journal mailbox? [y or
n]"
$database = read-host "Do you need to create a journal database? [y
or n]"
$name = read-host "Provide a name for the journal rule"
if ($database -eq "y") {
write-host "The next part of the script will ask for how many
databases to create. Choose 1." -foregroundcolor Green
create-database
} else {
$dbname = read-host "What database would you like to use for
journaling?"
}
if ($mailbox -eq "y") {
$journalmailbox = read-host "What will you call the journaling
mailbox?"
$password = read-host "Enter a password" -AsSecureString
$prefix = read-host "Enter a prefix for the User Principal Name
[i.e. @domain.local]"
$mailbox = $journalmailbox+$prefix
write-host "The $journalmailbox will be created in the Users OU"
new-mailbox -userprincipalname $mailbox -alias $journalmailbox database $tbd -displayname $journalmailbox -name $journalmailbox password $password
} else {
$journalmailbox = read-host "What is the name of the journaling
mailbox?"
}
if ($journaloption -eq "1") {
$nousers = read-host "How many users do you want to configure
journaling for?"
$counter = 0
$list = @()
while ($counter -lt $nousers) {
$user = read-host "What user do you want to configure for
journaling? [user alias]"
$email = (get-mailbox $user).primarysmtpaddress
$smtp = $email.local+"@"+$email.domain
$list += ,($smtp)
$counter++
}
# Configure journaling for the user
New-JournalRule -Name $name -JournalEmailAddress $smtp -Scope
Global -recipient $smtp -Enabled $true
} else {
# Configure journaling for the organization
$email = (get-mailbox $journalmailbox).primarysmtpaddress
$smtp = $email.local+"@"+$email.domain
New-JournalRule -Name $name -JournalEmailAddress $smtp -Scope
Global -Enabled $true
}
} # End the Configure Journaling function
# Configure Delegation
function Configure-delegation {
$userA = read-host "What user needs delegation rights? [enter the
user's alias]"
$userB = read-host "What user mailbox will have access granted to it?
[enter the user's alias]"
$accessrights = read-host "What access rights will be granted? [use
commas if more than one]"
$folder = read-host "All folders or specific folder [a or s]"
if ($folder -eq "a") {
$folder2 = "*"
$combo = $usera+":\"+$folder2
add-MailboxFolderPermission -Identity $userB -User $UserA AccessRights $accessrights
}
if ($folder -eq "s") {
$folder2 = read-host "Which folder will the rights apply to"
$combo = $usera+":\"+$folder2
# Add the folder tothe user's mailbox being modified"
$name = $userB+":\"+$folder2
add-MailboxFolderPermission -Identity $name -User $UserA AccessRights $accessrights
}
} # End the Configure Delegation function
# Configure Archive Quotas
function Configure-ArchiveQuotas {
# Added in version 1.3
write-host "Enter your Quota values:"
$awq = read-host "Archive Warning Quota [in MB, unlimited]"
if ([string]$awq -ne "unlimited") {
[string]$awq = [string]$awq+" MB"
}
[string]$aq = read-host "Archive Quota [in MB]"
if ($aq -ne "unlimited") {
[string]$aq = [string]$aq+" MB"
}
$answer = read-host "Do you want to apply the archive quota policies
to (a) all users, (r) random users or (c) use CSV files [a, r, c]"
# Configure all mailbox archive quotas
if ($answer -eq "a") {
$mailboxes = (get-mailbox | where {($_.RecipientTypeDetails -ne
"DiscoveryMailbox") -and ($_.archivestate -ne
"none")}).primarysmtpaddress
foreach ($line in $mailboxes) {
$primary = $line.local+"@"+$line.domain
set-mailbox $primary -ArchiveQuota $aq -ArchiveWarningQuota
$awq
write-host "The mailbox for $primary has had their archive
quotas modified as requested:" -foregroundcolor green
get-mailbox $primary | ft ArchiveQuota, ArchiveWarningQuota
}
write-host "Quotas configured for all mailboxes as requested."
# Configure Random mailboxes
}
if ($answer -eq "r") {
$mbxcount = (get-mailbox | where {$_.RecipientTypeDetails -ne
"DiscoveryMailbox"}).count
$range = get-random -minimum 0 -maximum $mbxcount
$counter = 0
$mailbox = (get-mailbox | where {($_.RecipientTypeDetails -ne
"DiscoveryMailbox") -and ($_.archivestate -ne
"none")}).primarysmtpaddress
while ($counter -lt $range) {
$address = $mailbox[$counter]
$primary = $address.local+"@"+$address.domain
set-mailbox $primary -ArchiveQuota $aq -ArchiveWarningQuota
$awq
write-host "The mailbox for $primary has had their archive
quotas modified as requested:" -foregroundcolor green
get-mailbox $primary | ft ArchiveQuota, ArchiveWarningQuota
$counter++
}
write-host "Quotas configured for $range mailboxes as requested."
}
# Configure mailbox archive quotas via CSV file
if ($answer -eq "c") {
$csvfile = read-host "Specify a CSV file (complete file path)
with alias, archivequota and archivewarningquota values"
$csv = import-csv $csvfile
foreach ($line in $csv) {
# Verify the account has an archive
$test = (get-mailbox $line.alias).archivestate
if ($test -ne "none") {
set-mailbox $line.alias -ArchiveQuota $line.archivequota
-ArchiveWarningQuota $line.archivewarningquota
$display = (get-mailbox $line.alias).displayname
write-host "The mailbox for $display has had their
archive quotas modified as requested:" -foregroundcolor green
}
}
}
start-sleep 5
cls
} # End the Configure Archive Quotas
Do {
if ($RebootRequired -eq $true){Write-Host
"`t`t`t`t`t`t`t`t`t`n`t`t`t`tREBOOT
REQUIRED!`t`t`t`n`t`t`t`t`t`t`t`t`t`n`t`tDO NOT INSTALL EXCHANGE BEFORE
REBOOTING!`t`t`n`t`t`t`t`t`t`t`t`t" -backgroundcolor red -foregroundcolor
black}
if ($opt -ne "None") {Write-Host "Last command: "$opt foregroundcolor Yellow}
$opt = Read-Host $menu
switch ($opt)
{
1 {# Create databases and replicas
create-database
dag-check
}
2 {# Create Mailboxes
create-mailboxes
}
3 {# Create Distribution Groups
$create = read-host "Are all mailboxes created [y or n]"
if ($create -eq "y") {
create-distributiongroups
} else {
write-host "Please create mailboxes before creating any
DL's!"
}
}
4 {#
Create Shared Mailboxes
create-sharedmailboxes
}
5 {# Create Rooms
$choice = read-host "Do you want to [1] create rooms or [2]
rooms and roomlists?[1 or 2]"
if($choice -eq 1) {
create-roommailboxes
} else { # Added an move advanced option (1.3)
New-RoomList
}
}
6 {# Populate email
populate-email
}
7 {# Populate calendars
# Create sample calendar entries and exported it to a PST
file
# Import these into random mailboxes
write-host "This function assumes you have the correct
rights." -fore red
write-host " "
start-sleep 5
Create-CalendarEvents
}
8 {# Populate Tasks
]
# Create sample calendar entries and exported it to a PST
file
# Import these into random mailboxes
write-host "This function assumes you have the correct
rights." -fore red
write-host " "
start-sleep 5
Create-Tasks
}
9 {# DLP Policy Creation -ForegroundColor Red
invoke-expression "c:\scripts\XMLScript-Lab-1.3.ps1"
}
10 {# Create retention Policies
create-retentionpolices
}
11 {# Configure quotas
configure-quotas
}
12 {# Configure disclaimers
Check-OldDisclaimers
Configure-NewDisclaimers
}
13 {# Configure Transport Rules
CLS
write-host " "
write-host "This menu option is not ready yet for
testing." -ForegroundColor Red
write-host " "
start-sleep 5
CLS
}
14 {# Configure Other Settings
CLS
write-host " "
write-host "This menu option is not ready yet for
testing." -ForegroundColor Red
write-host " "
start-sleep 5
CLS
}
15 { # Mobile Devices
create-mobiledevicepolicy
}
16 { # OWA Policies
create-OWApolicy
}
17 { # Enabling Archives
enable-archives
}
18 { # Configure Apps
configure-Apps
}
19 { # Configure Journaling
configure-journaling
}
20 { # Configure Delegation
configure-delegation
}
21 { # Configure Archive Quotas
Configure-ArchiveQuotas
}
22 { #Configure dynamic DLs
create-dynamicdistributiongroups
}
30 {# Assign impersonation rights to the current user account
add-impersonation
}
97 {# Remove all the above configurations
CLS
write-host " "
write-host "This menu option is not ready yet for
testing." -ForegroundColor Red
write-host " "
start-sleep 5
CLS
# Remove mailboxes, quotas, retention policies,
impersonation, distribution groups, etc
}
98 {# All of the above steps - walk through each function
CLS
write-host " "
write-host "This menu option is not ready yet for
testing." -ForegroundColor Red
write-host " "
start-sleep 5
CLS
}
99 {# Exit
if (($WasInstalled -eq $false) -and (Get-Module
BitsTransfer)){
Write-Host "BitsTransfer: Removing..." -NoNewLine
Remove-Module BitsTransfer
Write-Host "`b`b`b`b`b`b`b`b`b`b`bremoved!
" ForegroundColor Green
}
popd
Write-Host "Exiting..."
Stop-Transcript
}
default {Write-Host "You haven't selected any of the
available options. "}
}
} while ($opt -ne 99)
Download