Sitescope powershell script monitor, how to use parameter

Hi Experts

We have created a Powershell script that will display windows event logs that we want to monitor. We need to run this on a lot of server and we are using the script monitor and we need one of the paramters in the script that we specify to accomplish this task. See below command:

Get-EventLog -computer $remoteMachineName$ -After (Get-Date).AddDays(-2) "System" | Where-Object {$_.EventID -eq 10028}

the -computer is what we are interested in using as a parameter in the script monitor.

Any advise would be highly appreciated.

Regards

Sugan

Parents
  • Hi Sugan,

    you need to define your script monitor as a template using a variable for the remote host name. In the script monitor settings there's a field "Parameters" in which you can use the variable. When deploying your template for a specific remote system, the variable will be replaced with the actual hostname. When calling your PowerShell script SIS will append the parameter as command line option.

    Best Regards

         Bernhard

  • Hi Bernhard

    Thanks for your update. This is the first time I am doing this, how do we change the powershell script command, by adding the parameter? Can you try using the command in SiteScope and adding a parameter? The template part is fine, we basically need the monitor to work first before we apply it.

    Regards

  • Hi Sugan,

    have a look at the following page "https://devcentral.f5.com/articles/powershell-abcs-p-is-for-parameters" on how-to read command line parameters in PowerShell scripts. This is completely independent from SiteScope.

    SiteScope will call your script with the parameters you specify in the parameter field given as command line arguments

    Example: In SIS you configure your script "MyScript" and specify "a b c" in the parameters field.
    SiteScope will call your script using

    MyScript a b c

    Best Regards

           Bernhard

Reply
  • Hi Sugan,

    have a look at the following page "https://devcentral.f5.com/articles/powershell-abcs-p-is-for-parameters" on how-to read command line parameters in PowerShell scripts. This is completely independent from SiteScope.

    SiteScope will call your script with the parameters you specify in the parameter field given as command line arguments

    Example: In SIS you configure your script "MyScript" and specify "a b c" in the parameters field.
    SiteScope will call your script using

    MyScript a b c

    Best Regards

           Bernhard

Children