Examples
banshee/examples-collection/examples/protocols/
winrm-run
Example: winrm.run, a PowerShell script over WinRM; the state of a Windows service.
par banshee1 installation1 version
Publiée le 27 octobre 2026. First version in this collection.
// winrm.run: run a PowerShell script on a Windows, by WinRM over HTTPS. It returns output, errors and
// exit, as ssh.run does; WinRM starts PowerShell itself, so the script is written as it is.
// The collector reads the state of the print spooler.
need('protocol:winrm');
output('state', 'text', array('label' => 'State of the print spooler'));
watch.expect('stopped', 'Spooler not running', 'state', array('critical' => array('Running')));
$answer = winrm.run('(Get-Service -Name Spooler).Status.ToString()');
if ($answer['exit'] != 0) {
fail('misconfigured', 'Get-Service failed', $answer['errors']);
}
value('state', text.trim($answer['output']));