#--logging-(begin)-------------------------------------------------------------- [string] $logfile = ("$env:TEMP\diag_umsgthrottlecheck_"` + ((get-date).tostring("yyyyMMdd_HHmmss")) + ".txt"); # constants Set-Variable INFO -value ([int32] 0) -option readonly -force; Set-Variable WARN -value ([int32] 1) -option readonly -force; Set-Variable ERR -value ([int32] 2) -option readonly -force; # bitmask Set-Variable TOLOGFILE -value ([int32] 1) -option readonly -force; Set-Variable TODISPLAY -value ([int32] 2) -option readonly -force; Set-Variable TOBOTH -value ` ([Int32] ($TOLOGFILE + $TODISPLAY)) -option readonly -force; function timestamp() { (get-date).tostring("HH:mm:ss.fff"); } function log( [string] $str, ` [Int32] $nLevel = $INFO, ` [Int32] $nDestination = $TOBOTH ) { [System.ConsoleColor] $color = "white"; [string] $strOut = ""; [string] $strPrefix = "INFO: "; if($nLevel -eq $WARN) { $strPrefix = ("WARNING: "); $color = "yellow"; } elseif($nLevel -eq $ERR) { $strPrefix = ("ERROR: "); $color = "red"; } $strOut += ($str); if([bool]($nDestination -band $TOLOGFILE)) { add-content -path $logfile -value ((timestamp) + " " + $strPrefix + $strOut); } if([bool]($nDestination -band $TODISPLAY)) { write-host $strOut -foregroundcolor $color; } } function logw([string] $str) {log $str $WARN;} function loge([string] $str) {log $str $ERR;} #--logging-(end)---------------------------------------------------------------- function GetInputString([string] $str) { write-host $str -foregroundcolor cyan; log ("INPUT REQUEST: " + $str) $INFO $TOLOGFILE; [string] $strResponse = read-host ("==>"); log ("INPUT RESPONSE: " + $strResponse) $INFO $TOLOGFILE; return $strResponse; } function LogThrottlingPolicy([Microsoft.Exchange.Data.Directory.Management.Mailbox] $mbox) { $policy = $null; $policyLink = $mbox.ThrottlingPolicy; if ($policyLink -eq $null) { $policy = Get-ThrottlingPolicy | where-object {$_.IsDefault -eq $true} log ($mbox.name + " does not have an explicit ThrottlingPolicy assigned, therefore "` + "is subject to the default ThrottlingPolicy """ + $policy.name + """."); } else { $policy = $policyLink | Get-ThrottlingPolicy; log ($mbox.name + " is assigned to ThrottlingPolicy """ + $policy.name + """."); } $rcamax = $policy.RCAMaxConcurrency; if ($rcamax -eq $null) { log ("RCAMaxConcurrency value for " + $policy.name + " is null (unlimited)."); log ("This account is acceptable for use as the Cisco Unity Messaging Services "` + "account when Unity subscriber mailboxes are homed on Exchange 2010."); } else { logw ("RCAMaxConcurrency value for " + $policy.name + " is [" + $rcamax + "]."); logw ("The Cisco Unity Messaging Services account must be assigned to a "` + "ThrottlingPolicy having a null (unlimited) RCAMaxConcurrency value "` + "if any Unity subscriber mailboxes are homed on Exchange 2010."); } } function LogUser([Microsoft.Exchange.Data.Directory.Management.User] $user) { write-host ""; log ("Account Name: " + $user.name.tostring()); log ("[" + $user.distinguishedname.tostring() + "]"); $recipienttype = $user.recipienttype; log ("RecipientType: " + $recipienttype.tostring()); if ($user.recipienttype -ne "UserMailbox") { logw ("The Cisco Unity Messaging Services account must have RecipientType "` + """UserMailbox"" if any Unity subscriber mailboxes are homed on Exchange 2010."); } else { $usermailbox = (get-mailbox $user.guid.tostring()); log ("ExchangeVersion: " + $usermailbox.exchangeversion.tostring()); $majorver = $usermailbox.exchangeversion.exchangebuild.major; if ($majorver -lt 14) { logw ("This mailbox is has ExchangeVersion major build number """ + $majorver.tostring() + """."); logw ("The Cisco Unity Messaging Services account mailbox must have ExchangeVersion "` + "with major build number 14 or later if any Unity subscriber mailboxes are homed on Exchange 2010."); } else { LogThrottlingPolicy ($usermailbox); } } } log ("Begin Cisco Unity Messaging Service Account Exchange Throttling Policy Check Script")` $INFO $TOLOGFILE; $strInstructions = "Enter the name of the Cisco Unity Messaging Services Account"; [string]$strInput = ""; while ($true) { $strInput = (GetInputString $strInstructions); if ($strInput.length -lt 3) { logw ("Please enter at least three (3) characters"); } else { break; } } $strActivity = "Search for users matching the input string """ + $strInput + """"; write-progress -Activity $strActivity -Status "Searching is in progress..." ` -CurrentOperation "In organizations with a large number of users this could take a few moments." ` -Id 11 -ParentId -1 -PercentComplete -1 -SecondsRemaining -1; $users = get-user -anr $strInput -resultsize unlimited; write-progress -Activity $strActivity -Status "Complete" -Id 11 -Completed; write-host ""; if ($users -eq $null) { write-host ""; loge ("No Users accounts were found matching the input string """ + $strInput + """."); } elseif ($users -is [system.array]) { foreach ($user in $users) { LogUser($user); } } else { LogUser($users); } write-host ""; write-host ("Log file has been written to " + $logfile.tostring()); write-host "";