KBI 310917 Running PowerShell Remoting Scripts In Argent Guardian Ultra

Version

Argent Guardian Ultra 3.1A 1404 and below

Date

Wednesday, 16 Apr 2014

Summary

PowerShell remoting allows for the execution of scripts located on a local server to be executed remotely

There are several ways to invoke commands and run scripts remotely with PowerShell

The command ‘Enter-PSSession‘ may not work when used in an Argent Guardian Ultra – PowerShell Rule

Technical Background

Several PowerShell commands are meant for interactive mode execution (e.g. Keyboard Input) and may not work when executed from the Argent Guardian Ultra PowerShell execution context

Argent is still investigating this issue and may support this in future

Resolution

Use the command ‘New-PSSession‘ together with ‘Invoke-Command‘ as an alternative to ‘Enter-PSSession

Example PowerShell Script Remote Execution Rule:






$session = New-PSSession -ComputerName $PSPlayer.TargetServer



$remoteHostname = Invoke-Command -Session $session -ScriptBlock { hostname }



$remoteIpconfig = Invoke-Command -Session $session -ScriptBlock { ipconfig }



$remoteHostname



$remoteIpconfig



Remove-PSSession -Session $session

Note:

Replace ‘Get-Date‘ with the script that you wish to execute