Specific PowerShell script to shutdown a BizTalk receive location when a disk is more then 80% full. This application uses WMI to request disk info and shutdown the the receive location.
function fGetDiskFillPerc([string]$vComputer, [string]$vDiskID) {
$vCommandLine1 = "Get-WMIObject -ComputerName '" + $vComputer + "' Win32_LogicalDisk -filter `"DeviceID = '" + $vDiskID + "'`""
$vResult1 = Invoke-Expression $vCommandLine1
foreach ( $vDisk in $vResult1 ) {
if ($vDisk.DriveType -eq 3) {
[decimal]$dDiskFill = $vDisk.Size - $vDisk.FreeSpace
return $dDiskFill / $vDisk.Size * 100
}
}
}
[decimal]$dDiskFillPercResult = fGetDiskFillPerc "." "D:"
if ( $dDiskFillPercResult -gt 80 ) {
$oRecLoc1 = get-wmiobject MSBTS_ReceiveLocation -namespace 'rootMicrosoftBizTalkServer' -filter "Name='ReceivePortName'"
[void]$oRecLoc1.Disable()
}