PowerShell

PowerShell provides remote access of the monitored device and the ability to leverage PowerShell modules and .NET libraries installed there.

Prerequisites

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.

Monitor Configuration

Configuration fields for this active monitor include:

Available Monitor Objects and Attributes

PowerShell active monitor scripts have two instantiated session objects available.

Getting or Setting Properties for a Context Object

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")

Setting Result String and Monitor Status Indicator

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)

Context Object Properties

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)

Context Object Credential Properties

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.
values: 1 = None, 2 = MD5, 3 = SHA

CredSnmpV3:EncryptProtocol(integer-value)

Integer value can be one of the following:

  • 1 = None
  • 2 = DES56
  • 3 = AES128
  • 4 = AES192
  • 5 = AES256
  • 6 = THREEDES

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.

CredRestAPI:Username

User name needed to authenticate to the device.

CredRestAPI:Password

Password associated with the user name.

CredRedfish:Username

Username required for hardware device access.

CredRedfish:Password

Password required for hardware device access.

CredRedfish:Protocol

Protocol used for secure communication with the device.

CredRedfish:Port

Port number used to communicate with the device.

CredRedfish:Timeout

Length of time the connection should be attempted.

 

CredRedfish:Retries

Number of attempts WhatsUp Gold should use to communicate with the device.

CredRedfish:IgnoreCertificateErrors

Disregard certificate errors.

Example: Check if Service is Running

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 )

}

See Also

Active Monitors

Active Script (Active)

APC UPS (Active)

BGP Peer Status

Cloud Resource Monitor

DNS

Email

Exchange 2003

Exchange

Fan

File Content

File Properties

Folder

FTP

HTTP Content

JMX (Active)

Meraki Device Status Active Monitor

Network Statistics

Ping

Ping Interarrival Jitter

Power Supply

Printer

Process

REST API (Active)

Service

SMI-S

SNMP Extended

SNMP (Active)

SQL Query (Active)

SQL Server

SSH (Active)

SSL Certificate

Storage Controller Health monitor

Storage File System

Storage Disk Drives

Storage LUN

Storage Pool

TCPIP

Telnet

Temperature

VoIP

WAP Radio

WMI Formatted

WMI

Set Polling Properties

Apply Action to Monitor

Using Action Policies

Implicit Action Policy