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 retained for 90 days and includes both the executed commands and the Connect user who ran them. During this period, all entries can be viewed directly in the console.
  • Commands will be executed in the local system context, not the Local User. 
  • While this does resemble an interactive command shell, commands are executed using similar file based mechanics to a Script step in a Package deployment. Both PS1 and CMD commands are ultimately executed using PowerShell. 

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 the next 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 run in will be noted by "Cmd" or "PS" next to the command. 

 

Mac Support: Running Commands on macOS

PDQ Connect supports the ability to run Commands on registered macOS devices. The same general concepts from Windows devices apply with the following exceptions:

  • The default language used for the Commands feature on macOS is Zsh.
  • Bash is also available

Was this article helpful?