Introduction

The third command type with the MS PowerShell Sensor is the "Custom Script".
With that type you can trigger your OWN cmdlet.

You need to place your own cmdlets to the following path:

/opt/panagenda/scripts/gl_powershell/xxxxxxx.ps1

 

The following example is a MS SQL example which demonstrates what steps you have to follow.

 

Configuration

Make sure that you have all Requirements in place

Requirements / Authentication Profile / Server


Create/adjust your Powershell Script

First of all you need to adjust your script in a way that it follows the following requirements:

Custom Scripts - Guideline

 

example script for this kbase article:

function Get-ISqlAvailableServers{
<#
    .SYNOPSIS
        Get-ISqlAvailableSQLServers
    .DESCRIPTION
        Get available SQL Server instances
    .EXAMPLE
        .\Get-ISqlAvailableSQLServers
    .INPUTS
   

    .OUTPUTS
        Server names
    .NOTES      

    .LINK
#>

begin {
    [void][reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
}
process {
    try {
        Write-Verbose "Enumerating servers...please wait"
        # Enumerate servers
        $smoApp = [Microsoft.SqlServer.Management.Smo.SmoApplication]
        $enumServers = $smoApp::EnumAvailableSqlServers($false) | Select Name
        Write-Output $enumServers
    }
    catch [Exception] {
        Write-Error $Error[0]
        $err = $_.Exception
        while ( $err.InnerException ) {
            $err = $err.InnerException
            Write-Output $err.Message
        }
    }

}

}

 

Store Script on GL Appliance

copy your script to : /opt/panagenda/scripts/gl_powershell/Get-ISqlAvailableServers.ps1

 

Configure the MS Powershell Sensor

 

 

Output: