BuildMaster Documentation

Powershell - PSExec

  • Last Modified: 2020-06-26

This is generated from the built-in components of BuildMaster 6.2.13, and may be different than what you have installed (especially if you have extensions); go to [User Icon] > Documentation within your BuildMaster instance to see exactly what operations are available.


Executes a specified PowerShell script.

Script usage:

	Text: <text>,
	[Debug: <true/false>],
	[Verbose: <true/false>],
	[RunOnSimulation: <true/false>],
	[Isolated: <true/false>],
	[SuccessExitCode: <text>]

This operation may be prefixed with PowerShell::, although this is a built-in namespace and isn't really necessary.


Name Format Script Usage Usage Notes
Script contents (default)
The PowerShell script text. Variables are not expanded within the contents of this property. This argument is required.
Capture debug
Captures the PowerShell Write-Debug stream into the Otter debug log. The default is false.
Capture verbose
Captures the PowerShell Write-Verbose stream into the Otter debug log. The default is false.
Run on simulation
Indicates whether the script will execute in simulation mode. The default is false.
When true, the script is run in a temporary AppDomain that is unloaded when the script completes. This is an experimental feature and may decrease performance, but may be useful if a script loads assemblies or other resources that would otherwise be leaked.
Success exit code
Integer exit code which indicates no error. The default is empty, treating all exit codes as success. This can also be an integer prefixed with an inequality operator.

Note: This operation will inject PowerShell variables from the execution engine runtime that match PowerShell variable expressions. This means you won't get an error if you use an undeclared variable in your script, but some expressions that PowerShell interoplates at runtime (such as a variable inside of a string), cannot be replaced by the operation.

Note: If you are attempting to write the results of a Format-* call to the log, you may see messages similar to "Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData". To convert this to text, use the Out-String commandlet at the end of your command chain.

Note: This script will execute in simulation mode; you set the RunOnSimulation parameter to false to prevent this behavior, or you can use the $IsSimulation variable function within the script.


# writes the list of services running on the computer to the Otter log
psexec >>
    Get-Service | Where-Object {$_.Status -eq "Running"} | Format-Table Name, DisplayName | Out-String

# delete all but the latest 3 logs in the log directory, and log any debug/verbose messages to the Otter log
psexec >>
    Get-ChildItem "E:\Site\Logs" | Sort-Object $.CreatedDate -descending | Select-Object -skip 3 | Remove-Item
>> (Verbose: true, Debug: true, RunOnSimulation: false);

Is this documentation incorrect or incomplete? Help us by contributing!

This documentation is licensed under CC-BY-SA-4.0 and stored in GitHub.

Generated from commit ced119d5 on master