PowerShell provides remote access of the monitored device and the ability to leverage PowerShell modules and .NET libraries installed there.
WhatsUp Gold uses a 32-bit (in other words, "x86") PowerShell engine. Only 32-bit PowerShell snap-ins are supported and 64-bit only snap-ins will not function properly. Snap-ins that work on both 32-bit and 64-bit operating systems are configured for 64-bit systems by default and must be manually configured for 32-bit PowerShell engine to function properly with WhatsUp Gold.
Remote Connection Requirements
Ensure the following are in place for enabling the WhatsUp Gold machine to connect using PowerShell to the destination (polled) device.
Enable-PSRemoting
. Enable PowerShell remoting on destination (polled) device. For more information see link to MSDN documentation provided.Configuration fields for this active monitor include:
PowerShell active monitor scripts have two instantiated session objects available.
You can fetch values for context properties using PowerShell active monitor scripts.
Syntax
Property-Value = Context.GetProperty("
Property-Name")
Context.SetProperty("
Property-Name","
Property-Value")
Example
$DeviceIpAddress = $Context.GetProperty("Address")
$Context.SetProperty("Timeout", "180")
The result string you set will be added to the description in the monitor's status change. The status flag you set (0, 1) up/down determines the indicator shown in the State Change Timeline.
# After a successful Get of the deviceIP, Set as result and set success flag ...
$Context.SetResult(0, "Device IP address is: " + $DeviceIpAddress)
The following properties can be accessed from the connection object created when running PowerShell.
Property Name |
Description |
DeviceID |
WhatsUp Gold Device identification string. |
Address |
IP address. |
Timeout |
Timeout value for this session. (In seconds) |
The following credential properties can be set for the PowerShell. These are useful when you need to connect to other services, platforms, or applications after the initial PowerShell connection is made using the active monitor.
Property Name |
Description |
CredWindows:DomainAndUserid |
Domain and user for the Windows Credential. |
CredWindows:Password |
Set the Windows Password. |
CredSnmpV1:ReadCommunity |
SNMPv1 Read Community string. |
CredSnmpV1:WriteCommunity |
SNMPv1 Write Community string. |
CredSnmpV2:ReadCommunity |
SNMPv2 Read Community string. |
CredSnmpV2:WriteCommunity |
SNMPv2 Write Community string. |
CredSnmpV3:AuthPassword |
SNMPv3 password. |
CredSnmpV3:AuthProtocol(integer-value) |
SNMPv3 authentication protocol. |
CredSnmpV3:EncryptProtocol(integer-value) |
Integer value can be one of the following:
|
CredSnmpV3:EncryptPassword |
SNMPv3 Encrypted password. |
CredSnmpV3:Username |
SNMPv3 user. |
CredSnmpV3:Context |
SNMPv3 Context. |
CredADO:Password |
ADO password. |
CredADO:Username |
ADO username. |
CredSSH:Username |
SSH username. |
CredSSH:Password |
SSH password. |
CredSSH:EnablePassword |
Enable password flag. |
CredSSH:Port |
SSH port if other than default. |
CredSSH:Timeout |
Timeout for SSH session. |
CredVMware:Username |
VMware username. |
CredVMware:Password |
VMware password. |
CredTelnet:Timeout |
Time out value for telnet connection. |
CredTelnet:Port |
Telnet port (if other than default). |
CredTelnet:Username |
Telnet username. |
CredTelnet:Password |
Telnet password. |
CredJMX:Username |
Java Management Extensions username. |
CredJMX:Password |
Java Management Extensions password. |
CredSMIS:Timeout |
Storage Management timeout. |
CredSMIS:Port |
Storage Management port. |
CredSMIS:Protocol
|
Storage Management protocol. |
CredSMIS:Username
|
Storage Management username. |
CredSMIS:Password
|
Storage Management Password. |
CredAWS:AccessKeyID
|
Amazon Web Services account ID. |
CredAWS:SecureAccessKey
|
Amazon Web Services access key. |
CredAzure:TenantID
|
Azure subscription ID. |
CredAzure:ClientID
|
Azure Client account ID. |
CredAzure:SecureKey |
Azure account key. |
Create a PowerShell active monitor that shows status of up only if DNS client is running using stored credentials.
# Device to Poll
$DeviceIpAddress = $Context.GetProperty("Address")
# Set the computer name directly, or...
# $CompName = mydb02.corpnet.example.com (for example)
# ...get it using WMI...
$WmiRes = Invoke-Command -ComputerName $DeviceIpAddress -ScriptBlock { Get-WmiObject Win32_Computersystem }
$CompName = $WMIRes.PSComputerName
# Run command on remote device
$PsResult = Invoke-Command -ComputerName $DeviceName -ScriptBlock { Get-Service | where { $_.Name -match "Dnscache" } }
# Check for condition of 'running'
if ($PsResult.Status -match 'Running') {
$RespondingMessage = "Process '" + $processName + "' running on " + $DeviceIpAddress + " is responding."
$Context.SetResult(0, $RespondingMessage )
} else {
$NotRunningMessage = "Process '" + $processName + "' running on " + $DeviceIpAddress + " is not responding."
$Context.SetResult(1, $NotRunningMessage )
}