PowerShell Step Properties

<< Click to Display Table of Contents >>

PowerShell Step Properties

Use PowerShell steps to execute PowerShell commands on target computers (from within PowerShell.exe). (Pro or Enterprise mode required.)

IMPORTANT: PowerShell version 1 is not supported in PDQ Deploy.

Remote commands must be able to run silently. If user input is required (for example having to confirm Yes by pressing Y) the command will ultimately timeout. If you need user interaction, you must set the Run As option to Deploy User (Interactive) or Logged on User. For more information about Run As settings, see Run As in Deployments Preferences.

The example below demonstrates terminating a process, in this case Firefox, in PowerShell.

The example below demonstrates multiple lines and environment variables. This script creates a shortcut to notepad.exe and places it on the Public Desktop for all users.

The example below demonstrates inserting a PowerShell script by clicking the Insert PowerShell Script link.

PowerShell Properties

Property

Details

PowerShell

Enter the command you want executed on the target computer. The syntax for the command is the same as when running commands in PowerShell.exe. Multiple commands are supported—enter one command per line.

The command is executed on the target computer in the %SystemRoot%\AdminArsenal\PDQDeployRunner\service-n\exec directory. You can also specify commands and specific paths for files at other locations.

If the command requires user interaction, set Run As (on the Options tab) to Logged On User or Deploy User (Interactive). For details about the Run As option, see Deployments Preferences.

NOTE: Write-Output is recommended over Write-Host for formatting purposes.

Note: The PowerShell step includes some basic error handling. For more detailed information on error handling, see PowerShell Error Handling.

 

Insert PowerShell Script

This will attach a PowerShell script (.ps1) file to your package and call that file from within the PowerShell Step. The included file will be listed in the Files field of the step.

Files

Select any additional files you wish to include with the command. This is useful for running utilities that may not be installed on all target computers or for including configuration files.

These files are copied into the %SystemRoot%\AdminArsenal\PDQDeployRunner\service-n\exec directory on the target computer.

Success Codes

The success or failure of the PowerShell step is determined by its return code. A command is considered a success if the return code is listed in the Success Code box.

For programs not native to PowerShell, PowerShell has a built-in variable called $LastExitCode that stores the last return code. This behaves similar to the %ERRORLEVEL% from a regular command line.

For native PowerShell cmdlets, no return code is given. Any native PowerShell cmdlets that encounter an error will return a PackagePowerShellErrorException for the step.

Note: The PowerShell step includes some basic error handling. For more detailed information on error handling, see PowerShell Error Handling.

Command Line

This is the command that will be executed on the target computer.

 

 

 

 

© 2017 PDQ.com Corporation. All rights reserved.

PDQ.com is a trademark of PDQ.com Corporation. All other product and company names are the property of their respective owners.

Help Version: 13.1.0.0