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