References > Aliases > Setup Windows PowerShell Monitor in SAM

Setup Windows PowerShell Monitor in SAM

Create and test the SAM PowerShell monitor using the following steps:

  1. From the SAM web console, navigate to: Settings > SAM Settings > Manage Templates.
  2. Search for "PowerShell."
  3. Select a template by checking the box next to the template name, an then clicking Edit.
  4. Click [+] to the left of a monitor name to reveal its details:
  5. You must choose Remote Host as the execution mode.
  6. Check the Use HTTPS Protocol setting.
  7. The Port Number value, (the default value is 5986 for WinRM secure connection), should correlate with the port on which the Listener was created on the Remoting Server.
  8. Enter a simple script in the monitor for testing by clicking Edit, for example:
    write "Statistic.RemoteMachineName: 0";
    write "Message.RemoteMachineName: $env:computername";
    exit 0;
    Note: This script is printing the computer name (the machine on which this is executed).
  1. Define the output columns for the script:
  2. View the script output:

  3. Create an application based on our template and assign it to the Remoting Server target node:
  4. Examine the script output. Done correctly, you should see the name of  the Remote Server node in the output, not the SAM server, ( i.e. the script was executed remotely).

You now have a PowerShell monitor configured to execute scripts remotely via secure WinRM connection.