Documentation forServer & Application Monitor

Use PowerShell in SAM

Created by Microsoft, PowerShell is a task automation and configuration management framework that consists of a command-line shell and associated scripting language, built on the .NET Framework. PowerShell is included in most installations of Microsoft Windows Server or you can install it, if necessary.

Many SAM features, such as AppInsight for IIS and AppInsight for Exchange, leverage PowerShell to execute commands and gather information from remote, target systems. Several SAM templates use PowerShell and it can also be used to interact with the Orion Platform in many ways. For example, use it with the Orion Software Development Kit (SDK) to perform IP Address Manager (IPAM) operations, such as creating subnets.

The ability to deploy PowerShell scripts to remote machines within SAM is a powerful advantage for system administrators. With an interactive prompt and scripting environment, PowerShell provides access to the file system on remote computers, along with data stores such as the registry. It includes built-in commands with a consistent interface (as shown here), plus an Integrated Scripting Environment (ISE) host application.

PowerShell does not process text; it processes objects based on the .NET Framework.

PowerShell also includes default cmdlets — simple commands you can use to manipulate objects — and you can write your own cmdlets. Cmdlets have a unique format — a verb and noun separated by a dash (-), such as Get-Help. You can use them separately or combine them in scripts that perform complex tasks.

Some ways you can use PowerShell with SAM include:

SolarWinds provides customer support for PowerShell scripts and functionality built into SAM, but not for scripting languages or custom scripts. For scripting support from the SolarWinds online IT community, visit THWACK.

Review these topics to learn more:

PowerShell security considerations

Depending on how you configure PowerShell in your environment, it can make your system vulnerable to unauthorized access. For example, running monitors in Local Host mode on the Orion server with Admin privileges gives scripts unlimited power. Your organization should internally review and assess to what extent PowerShell scripts will be incorporated into your environment. This is especially important when importing scripts from third parties, including content posted by other customers in the SolarWinds online IT community, THWACK.

When used in Orion Platform modules such as SAM, PowerShell can be a powerful tool that provides the ability to:

  • Access file systems on computers.
  • Access data stores, including the system registry.
  • Deploy scripts to run on multiple remote machines.

While PowerShell enhances SAM functionality, it's important to consider the security risks inherent in using PowerShell scripts. SolarWinds recommends the use of a dedicated Windows account with low-level privileges for PowerShell monitors, especially for scripts executed on a polling engine that uses the same Windows account as the Orion server.

You can also avoid security risks, such as malicious OS command injections, by using PowerShell's built-in security, as described in Microsoft PowerShell documentation (© 2018 Microsoft Corp., link available at, obtained on October 30, 2018).

PowerShell requirements

Following are PowerShell requirements for a typical SAM environment:

  • PowerShell version: Version 1.0 or later is required for local execution. For remote execution of scripts, PowerShell 2.0 or later is required on the main polling engine (that is, the Orion server), Additional Polling Engines (APEs), and target servers. PowerShell is included in most versions of Windows Server or you can install it, if necessary.

    Some scripts require PowerShell 2.0 to execute certain actions. Later versions of PowerShell shipped with Windows Server include a backwards compatibility mode you can enable to run 2.0 with a later version.

    Another consideration is whether to use 32-bit (x84) or 64-bit (x64) PowerShell. For best results, match the PowerShell version to the OS and application configurations on a server. For example, on a 64-bit main polling engine that polls a 64-bit server, use PowerShell 64 bit (x64).

  • Accounts and permissions: Local Admin rights are required to run scripts on the Orion server. To execute scripts on target servers, select a Windows credential with rights to log into the Orion server plus sufficient rights on the target node to execute tasks in the script. For example, if a script does something with WMI, the credentials also need WMI rights on the target node.

    SolarWinds recommends using a dedicated Windows account with minimal privileges for PowerShell monitors, especially for scripts executed on the main polling engine.

    Without the correct permissions for a target server, scripts return an Unknown status.

  • Microsoft .NET Framework: Many PowerShell scripts require .NET 3.5.x but most Orion Platform products include later versions. For example, SAM 2019.4 includes .NET 4.8. If necessary, use Server Manager's Add Roles and Features wizard to add .NET Framework 3.5.x.
  • Remote access: To use Remote Host as the Execution Mode for a PowerShell script, enable the Windows Remote Management (WinRM) service on the Orion server so it can access remote target servers, as described next.

To ease PowerShell plug-in management in an environment with multiple polling engines, consider assigning all nodes with PowerShell templates to a single polling engine.

Enable remote access for PowerShell with WinRM

To support SAM features such as AppInsight for IIS, the WinRM service must be enabled and properly configured on the main Orion server. WinRM cannot be enabled on target servers remotely, but you can configure the Orion server to grant permission for PowerShell to access the target servers.

There are several automated ways to enable remote access for PowerShell on servers, including:

To enable WinRM quickly from the command prompt:

  1. On the Orion server, open a command prompt as an Administrator, and enter the following:
    winrm quickconfig –q winrm set winrm/config/client @{TrustedHosts="*"}
  2. On each target server, open a command prompt as an Administrator and enter the following:
    winrm quickconfig winrm set winrm/config/client @{TrustedHosts="IP_ADDRESS"}

Another way to enable remote access for PowerShell manually is to follow these steps:

  1. On the Orion server and each remote server you want to run PowerShell on:
    1. Change the startup type for the WinRM service to Automatic.
    2. Start the WinRM service.
    3. Run the get-service winrm PowerShell command to verify WinRM is running.
  2. On the Orion server, click Start > Accessories > Windows PowerShell > Windows PowerShell.
  3. In the PowerShell console, run:
    Set-PSSessionConfiguration Microsoft.PowerShell -ShowSecurityDescriptorUI -force
  4. Enable the "Full Control for everyone" option.
  5. Verify the group to which the polling user belongs can access PowerShell.
  6. Repeat these steps for all remote target servers.

When finished, each remoting server should include the following elements:

  • An SSL certificate
  • A WinRM Listener
  • A firewall exception to allow outside requests to reach the WinRM service
  • The WinRM service to receive requests from other computers

The following log file contains information and errors related to the WinRM configuration process: C:\ProgramData\Solarwinds\Logs\APM\RunWinRMConfigurator.log

Use Microsoft Exchange Management tools

Many SAM PowerShell components rely on Exchange Management tools.

To monitor a specific version of Microsoft Exchange:

  • Use the corresponding version of Exchange Management Tools.
  • Install Exchange Management Tools on the Orion server and Additional Polling Engines that use PowerShell scripts.
  • Review Set PowerShell permissions for Exchange.

Learn more about PowerShell