The Commands Tool

PDQ Connect allows you to execute PowerShell commands and Command Prompt (CMD) commands from the device details page. The Commands tab will display the output directly in the interface, allowing you to perform quick actions and troubleshooting without the need to create a dedicated package 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 the output. Most commands will fully execute and return within seconds. 

Features and Considerations

  • PowerShell is the default environment for executing commands. This can be changed to CMD by toggling the "PS" button to "Cmd" near the input field. 
  • 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 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

The screenshot below shows the output of both commands, with the second line throwing an error unless connected with a semicolon. 

Running CMD Commands

In cases where a command must be run in a Command Prompt environment, you can toggle the language using the drop-down button next to the command input field. This can be useful when referencing variables that are specific to CMD. When viewing the output of a command, the language that a command was ran in will be noted by "Cmd" or "PS" next to the command. 

 

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