Exchange Scripts

Remove Poison Queue

Get-Queue IDENTITY\IDENTITY| get-message | ft -a -wr

Remove-Message IDENTITY

ISCSI Script

$targets = @(gwmi -Namespace “root\wmi” -Class MSiSCSIInitiator_TargetClass)

$sessions = @(gwmi -Namespace “root\wmi” -Class MSiSCSIInitiator_SessionClass);

 $sessions | select -unique TargetName, @{Name=”Status”;expression={if (compare-object $_ $targets -Property TargetName -ExcludeDifferent -IncludeEqual) {“Active”} else {“Inactive”}}} | ft -auto -wrap
Get-Counter -Counter “\System\Processor Queue Length” 
 
“Average CPU Usage per 10 samples: $([math]::round((get-counter -Counter “\Processor(_Total)\% Processor Time” -SampleInterval 1 -MaxSamples 10 | select -ExpandProperty countersamples | select -ExpandProperty cookedvalue | Measure-Object -Average).average,2))%”
 
get-wmiobject Win32_PerfFormattedData_PerfProc_Process |?{$_.name -ne “_Total” -and $_.name -ne “Idle” -and $_.percentprocessortime -ge 10} |select @{n=”Application”;e={$_.name}},@{n=”CPU”;e={$_.PercentProcessorTime}} | Sort-Object CPU -Descending | ft -auto
 
Failover
 

Get-MailboxDatabase | Sort Name | ForEach {$db=$_.Name; $xNow=$_.Server.Name ;$dbown=$_.ActivationPreference| Where {$_.Value -eq 1}; Write-Host $db “on” $xNow “Should be on”$dbOwn.Key -NoNewLine; If ( $xNow -ne $dbOwn.Key){Write-host ” WRONG” -ForegroundColor Red; } Else {Write-Host ” OK” -ForegroundColor Green}}  

 

Get-MailboxDatabaseCopyStatus USCULXMSG17 

 

Move-ActiveMailboxDatabase EXCHPRODAPP6-DB01 -ActivateOnServer EXCHPRODAPP6 -SkipClientExperienceChecks  

 

Get-MailboxDatabase | Sort Name | ForEach {$db=$_.Name;$xNow=$_.Server.Name ;$dbown=$_.ActivationPreference| Where {$_.Value -eq 1}; Write-Host $db “on” $xNow “Should be on” $dbOwn.Key -NoNewLine; If ( $xNow -ne $dbOwn.Key){Write-host ” WRONG” -ForegroundColor Red; } Else {Write-Host ” OK” -ForegroundColor Green}} 

 

Get-MailboxDatabaseCopyStatus xxxxDB0x 

 

Test-ServiceHealth