Running PowerShell Commands with PDQ Connect

Overview

You can execute PowerShell commands without deploying a package for any device in PDQ Connect. The Commands feature enables you to troubleshoot devices, gather information, and perform quick actions without needing to package the command first.

Accessing the Commands Feature

To begin executing commands, go to the Commands tab on any individual device page. From here, you will be presented with a console where you can run PowerShell commands and view their output. Most commands will fully execute and return within seconds. 

Features and Considerations

  • Command history is stored indefinitely. Additionally, we log and display which Connect user ran a specific command. If you want to see what command was ran on a machine 3 weeks ago and who ran it, simply scroll up in the console to review the history. 
  • Commands are currently designed to only run at the device level. If you would like to run a command on multiple devices, you would need to create a Package that utilizes a PowerShell Step. 
  • Commands will be executed in the local system context, not the Local User. 

Running Multiple Commands in Sequence

The Commands tool will only accept one command at a time. Attempting to paste a script with multiple lines into the Run Command field will result in errors when processing a new line. Just like in PowerShell, however, you can use a semicolon to connect multiple commands on a single line. For example:

Below we have two commands on separate lines. Copying both lines as-is will fail with an error starting with the second line. 

$FolderPath = "C:\Folder"
New-Item $FolderPath -ItemType Directory

If you connect the two lines with a semicolon, the command will succeed. You can add additional commands by adding more semicolons, but we recommend creating a Package with a PowerShell step for lengthy scripts. 

$FolderPath = "C:\Folder" ; New-Item $FolderPath -ItemType Directory

Running CMD Commands

The Commands tool will natively run all commands using PowerShell. In the rare cases where a command must be ran in a Command Prompt (cmd) environment, you can pass the command to cmd.exe by prefacing the command with "cmd /c" then entering the command. 

 

Still have a question or want to share what you have learned? Visit our Community to get help and collaborate with others.