PowerShell Scripting
- Last Updated: December 11, 2024
- 4 minute read
- WhatsUp Gold
- Version 2024
PowerShell Scripting enables you to create custom performance monitors using Windows PowerShell.
Important: WhatsUp Gold uses a 32-bit (i.e. x86) PowerShell engine.
Therefore, only 32-bit PowerShell snap-ins are supported and 64-bit only snap-ins will
not function properly. Snap-ins usable in 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.
The PowerShell Scripting performance monitor requires the following credential:
- Windows
Configure the PowerShell Scripting performance monitor using the following boxes:
- Name. Name for the performance monitor. This name displays in the Monitor Library.
- Description. Optional description for the performance monitor that displays as column data in the Monitor Library.
- Timeout. Duration WhatsUp Gold attempts to connect to the selected device. This is considered a failed connection.
- Polling Interval. Specify how often WhatsUp Gold should request updated information from the device.Note: Though the maximum timeout allowed is 60 seconds, we do not recommend setting a timeout exceeding 10 seconds. You are encouraged to use the shortest timeout possible.
- Reference variables. Add, edit, or remove SNMP and WMI reference
variables. See steps below to configure either an SNMP or WMI PowerShell Scripting
Performance monitor.Note: The use of reference variables in the PowerShell performance monitor is optional. If you do use them, you must use
Context.GetReferenceVariable, for reference variables to be polled and their data graphed. Reference variables simplify your scripting code and enable you to write scripts efficiently, without having to use a list of device properties, as with the Script Action and Script Active Monitor. They manage the underlying SNMP or WMI mechanisms you would normally have to manage in order to access SNMP or WMI counters on a remote device.By using theContext.GetReferenceVariable(variable name), you only need to specify the name of a pre-defined variable. WhatsUp Gold uses device credentials and connects to the target device using SNMP or WMI to retrieve the requested information. This information is stored in a variable that you can use later in your script. For more information, see Using the Context Object with Performance Monitors. - Run using Windows credentials assigned to the device. Enable this option to execute the script using the Windows credentials for the affected device.
- Script text. Enter your monitor code.Important: The first time that you poll a WMI reference variable that requires two polls in order to calculate an average (such as "Processor\% Processor Time"), it returns "Null."
To configure an SNMP PowerShell Scripting performance monitor:
- Click
from the Powershell Scripting Performance Monitor dialog to add a new variable to the Reference variables field. The Add New Reference Variable dialog appears. - Enter the appropriate information:
- Variable name. Enter a unique name for the variable.
- Description. (Optional) Enter a short description for the variable.
- Select the SNMP radio button.
- Enter the Timeout and Retries count for connection to the device. These are optional field entries.
- Click Select to launch the MIB Browser.
- Enter the name or IP address of the computer you are you are trying to connect to in the Select counters from computer box. You can click browse (...) to select a device from a list.
- Select the SNMP Credential used to connect to the device. You can also click browse (...) to access the Credentials Library to create a new credential.
- Adjust the length of time and the number of retries for the computer you are trying to connect to in the Timeout and Number of retries boxes.
- Click OK.
- Use the navigation tree to select the specific MIB you want to monitor. You can view more information about the property/value at the bottom of the dialog.
- Click OK to add the OID to the Performance counter and Instance fields in the Add New Reference Variable dialog.
- Verify the configuration and click OK to add the variable to the Reference variables list in the Powershell Scripting Performance Monitor dialog.
- Write or paste your monitor code in the Script text field.
- Click OK to save changes.
To configure a WMI PowerShell Scripting performance monitor:
- Click
from the Powershell Scripting Performance Monitor dialog to add a new variable to the Reference variables field. The Add New Reference Variable dialog appears. - Enter the appropriate information:
- Variable name. Enter a unique name for the variable.
- Description. (Optional) Enter a short description for the variable.
- Select the WMI radio button.
- Click Select to launch the MIB Browser.
- Enter the name or IP address of the computer you are you are trying to connect to in the Select counters from computer box. You can click browse (...) to select a device from a list.
- Select the Windows Credential used to connect to the device. You can also click browse (...) to access the Credentials Library to create a new credential.
- Click OK.
- Use the navigation tree to select the specific MIB you want to monitor. You can view more information about the property/value at the bottom of the dialog.
- Click OK to add the OID to the Performance counter and Instance fields in the Add New Reference Variable dialog.
- Verify the configuration and click OK to add the variable to the Reference variables list in the Powershell Scripting Performance Monitor dialog.
- Write or paste your monitor code in the Script text field.
- Click OK to save changes.