Run PowerShell 7 Script

Available for Windows (64-bit) only

This Automation Manager object runs a PowerShell 7 script. This object contains all components required to run PowerShell 7 scripts, so you do not need to install PowerShell 7 or are additional .NET runtime components on end devices.

PowerShell Module Support

The PowerShell 7 object supports standard PowerShell 7 cmdlets and can also use compatible PowerShell modules. This includes:

  • Built-in PowerShell 7 functionality.
  • Compatible custom modules.
  • Modules already installed on the managed endpoint, where supported.

Because PowerShell 7 differs from PowerShell 5.1 some legacy modules may not be compatible. You should validate compatibility before migrating automation policies to the new PowerShell 7 object.

Execution Context Compatibility

To help maintain compatibility with existing automation workflows, the PowerShell 7 object supports common Automation Manager execution contexts, including:

  • Local System
  • Custom credentials
  • Device credentials
  • Currently logged-on user

Editor enhancements

  • PowerShell syntax highlighting
  • Line numbers
  • Current line highlighting
  • Word wrap support
  • Auto-complete parameter: Typing $ presents available input and output parameters for adding into scripts.
  • Font scaling and zoom: Built-in zoom controls and mouse scroll shortcuts.
  • Editor window behaviour: Opens maximized by default, and remembers the last window size/position.
-   Do not use $Result and $ResultString variables
Do not use $Result and $ResultString variables in the embedded PowerShell script. These variables are reserved for internal use only and may cause the object to not execute properly.
-   Password Security
Be aware that password parameters are not safe when passed to this object as they are treated as regular System.String values.

Privileges

Normal

Input Parameters

Name Type Required Description
Script String Yes The contents of the PowerShell script.
Input Parameter List User Configurable No Input parameters are created by the user.

Passwords that contains a single quote (apostrophe), the single quote must be replaced by two single quotes when entering the password into a password field. For example, if the password is ab'cd, enter ab''cd (where '' is two single quotes and not a double quote) into the password field.

Where the input parameter is a Number type, and the value is the maximum allowable (1E+308), it will not be valid when run in (Undefined variable: N-sight.ProductName_nc).

Output Parameters

Name Type Required Description
Output Parameter List Configurable No Output parameters are created by the user.
Result Number   Returns a success value of zero or any value other than zero to indicate failure.

Example Input Parameters

Name Type Required Example
Input Parameters User Configurable No Optionally create input parameters to be used within the Script.
Script String Yes Paste PowerShell script contents.
Output Parameters User Configurable No Optionally create output parameters to be used within the Script.

Any value other than 0 will cause a policy run with the Run PowerShell Script object to fail.

Run as Current Logged on User Boolean No Optionally run the script as the current logged on user.