Function “IsActiveNode”
function IsActiveNode { $activeClusterName = (Get-WMIObject Win32_ComputerSystem -ComputerName BIZTALK2013).Name $computerName = get-content env:computername $message = "ActiveCluster=$activeClusterName computerName=$computerName" $isSame = $false if ($activeClusterName -eq $computerName) { $isSame = $true } $message = $message + " IsSame=$isSame" #Write-Host $message return $isSame } cls $IsActiveNodeResult = IsActiveNode Write-Host "IsActiveNode=$IsActiveNodeResult"
Sample test:
. .\IsActiveNode.ps1 cls $IsActiveNodeResult = IsActiveNode Write-Host "IsActiveNode=$IsActiveNodeResult" if ($IsActiveNodeResult -eq $false) { Write-Host "exiting - no action to be taken on inactive node" return } Write-Host "We are still here"