TL;DR: You can run remote PowerShell commands using native cmdlets like Enter-PSSession, New-PSSession, and Invoke-Command over WinRM. For remote command execution at scale, PDQ supports custom PowerShell and CMD scripts for endpoint automation, including one-off commands, reusable script packages, and automated deployments across devices or groups.
Running PowerShell commands against remote computers opens up a world of possibilities for endpoint management and automations. But just like any good Slurpee machine, you’ve got several options to choose from. Let’s take a look at some of the most common methods to run remote PowerShell commands — and a few easy alternatives.
Which PowerShell cmdlets run commands on remote computers?
PowerShell remoting makes it easier to manage remote devices with cmdlets like Enter-PSSession, New-PSSession, and Invoke-Command. On Windows, PowerShell remoting commonly uses WSMan/WinRM, while PowerShell 6 and later can also use SSH.
Running commands on remote computers is nothing new. Sysadmins have been supporting remote devices long before Ferris Bueller ever missed a day of school. But the process has changed over the years. For many, PsExec — the ever-popular Sysinternals utility — was a mandatory part of their sysadmin toolkit, allowing them to run commands and execute programs remotely.
Enter-PSSession
Enter-PSSession starts an interactive session with a remote device. You can think of Enter-PSSession almost as if you were physically working directly on the remote device. Enter-PSSession is great for interacting with one remote device at a time.
Here’s a basic example of Enter-PSSession.
Enter-PSSession -ComputerName <computer_name>
This simple command should give you a direct session with the remote computer. If you have any issues connecting, make sure you enable WinRM.
When you connect to a remote computer, you should see the computer name in brackets at the beginning of your shell prompt. But you can also verify the connection by returning some information that would be specific to the target device. For example, I could return the disk information of the connected device.

In the image above, you can see that I returned the C: drive information for my local device using the cmdlet Get-PSDrive. Then, I used Enter-PSSession to connect to a remote device and returned the C: drive data of the remote device. As expected, the data that was returned was unique to each endpoint.
When you’re ready to end the session and return back to your local console, just enter the keyword, exit.
New-PSSession
New-PSSession is great for creating persistent connections to remote targets. You can assign persistent sessions to a variable and enter the session at any point using the Enter-PSSession command.
New-PSSession -ComputerName <computer_name>
This command created a new remote session with a remote computer. However, you can see after calling the computer name environment variable, I’m not in the session I created. I’m still on my local device. But this created the remote session, which I can now connect to and exit from at will as long as I don’t delete the session or close the console.
Now I can use Enter-PSSession to connect to my persistent remote sessions.
Enter-PSSession -Name <runspace_name>
This command allows me to enter the remote session I created using the runspace name or session ID, which I can return by running Get-PSSession. However, best practice is to actually assign the remote session to a variable, like this:
$sesh = New-PSSession -ComputerName <computer_name>With the session assigned to a variable, we can refer to it without needing to remember the Runspace name or session ID.
The real power of New-PSSession comes from its ability to open several remote sessions at once by simply adding more remote targets to the command.
$sesh = New-PSSession -ComputerName <computer_name1>, <computer_name2>, <computer_name3>
Assigning multiple remote sessions to a variable lets you quickly send commands to multiple remote devices. For example, now I can return the disk information for each remote computer assigned to my session variable at once using the Invoke-Command cmdlet.
Invoke-Command -Session $sesh -ScriptBlock {Get-PSDrive C | Select-Object -Property Name, Free, Used}
Invoke-Command
Invoke-Command is another native PowerShell cmdlet that lets you fire off commands to remote computers. With Invoke-Command, you can target multiple remote computers at once or use existing remote sessions like in the previous example.
Invoke-Command is usually accompanied by a list of computers or an existing remote session to target and a script block containing the command you want to run on the remote devices. Here’s the general syntax of Invoke-Command.
Invoke-Command -ComputerName <computer_name1>, <computer_name2> -ScriptBlock {Command-ToRun}Here’s an example:
Invoke-Command -ComputerName AANG, TOPH, KATARA -ScriptBLock {Get-WindowsEdition -Online}
In this example, I use Invoke-Command to target three computers defined by the -ComputerName parameter. Then, inside the -ScriptBlock parameter, I run the command Get-WindowsEdition -Online against the remote targets.
The results for the Windows edition on the remote computers returned Professional edition. When I run the same command against my local machine, it returns ServerStandard.
I like to use Invoke-Command when a command doesn’t support the remote targeting I need. Some PowerShell cmdlets include a -ComputerName parameter, but support varies by cmdlet and PowerShell version. For example, Get-Service supported -ComputerName in Windows PowerShell 5.1, but PowerShell 6 and later require PowerShell remoting to query services remotely. You can use Get-Help or Get-Command -ParameterName ComputerName to see which cmdlets support the parameter.
How to run commands using PDQ
PDQ lets you run PowerShell or CMD commands on internet-connected Windows devices through the PDQ agent, so the device does not need to be connected to your local network or VPN. You can run one-off commands from the Commands tool or deploy reusable script packages to multiple devices. PDQ also supports Bash and Zsh commands and scripts on managed macOS devices.
That one user that basically lives at Starbucks? Piece of cake. Ken Adams who is currently backpacking through Western Europe? No problem. Matthew McConaughey as he travels through a wormhole to a distant solar system? Not yet, but a guy can hope.
Get extra inventory data with PowerShell
You can also use the PowerShell Scanner in PDQ to collect custom inventory data from Windows devices. Scanner results can be used in filters, dynamic groups, reports, and automation targeting, so you can identify devices that meet specific conditions and automatically target them for remediation.
PDQ commands console
The Commands tool in PDQ lets you run one-off PowerShell or Command Prompt commands against an individual remote Windows device and view the output directly in the console. It’s great for running commands against one device at a time.
To use the commands console in PDQ, click on a device, then click the Commands tab.

You can use the drop-down menu to change between PowerShell and Command Prompt. When you’re ready, enter a command, then click Run command.

In this example, I ran Get-WindowsOptionalFeature -Online to see which features were enabled on this PC. PDQ then returned all the information to the commands window.
Deploying commands and scripts to remote devices with PDQ
If you need to run commands against multiple remote endpoints managed by PDQ, the best way to do it is by creating a custom script package.
In PDQ, click the Packages tab.
Click Create package.

Name the package.
Click the drop-down arrow next to Add install step, then click Add script step.

Set the script type, either PowerShell or CMD. I’ll use a CMD command for this example.
Click the Import link to import a script, or type your command into the scripting pane.

When finished, click Save to save your package.
With your package saved, it’s ready to deploy to all those users working in Timbuktu — or Cleveland. Simply select the package you just created (it’ll be located in the Packages tab), then click Deploy. Add your devices or groups to the deployment, then click Deploy.

Within minutes (more likely, seconds), your deployment surfs its way across the web to the targeted devices. If you want to see the results of the deployment, you can click on the Deployments tab, then click the status link of one of the devices you deployed the script to.


Congrats! You’re ready to execute commands on a global scale. Next stop, deploying commands to space? I’ll reach out to my contacts at NASA.
How to run remote commands with PDQ's on-prem tools
PDQ Deploy & Inventory work together to run remote commands and provide automation capabilities. PDQ Inventory identifies and groups the computers you want to target, while PDQ Deploy runs or schedules packages and scripts against those targets.
Inventory: Find devices and organize them with static or dynamic collections.
Deploy: Run PowerShell, CMD, application, and patch packages against those collections.
How to run remote commands with PDQ Inventory
PDQ Inventory lets you run Command Prompt or PowerShell commands against one or multiple on-prem Windows computers directly from the console. You can use Run Command for one-off tasks or create custom tools for reusable workflows.
In PDQ Inventory, select a computer (or multiple computers).
Right-click on the selection, then click Tools, then click Run Command.

Enter your command into the command line, then hit the Execute button.

When your command finishes executing, the run command window displays the output from the remote device(s).

There are a few other things I should point out in this window. Next to the command line, there is a drop-down option to change to a PowerShell prompt. You can also select the Multi-line option to add commands that are more than just one-liners. You can configure different settings by clicking the Options drop-down menu, such as the run as mode, the timeout settings, success codes, and more. Lastly, you can add more targets by right-clicking in the computers field in the bottom left of the window, then clicking Choose Computers.

Once you get comfortable running commands from PDQ Inventory, take things to the next level by building your own custom tools in PDQ Inventory.
How to deploy commands and scripts to remote devices with PDQ Deploy
PDQ Deploy is well known for simplifying application and patch deployments. But did you know that Deploy also makes sending out commands and scripts to on-prem devices easier than sleeping through your alarm on a Monday morning? Here’s how easy it is to distribute commands and scripts using PDQ Deploy.
In PDQ Deploy, click the New Package button.
Enter a name for the package, then click New Step > Command or New Step > PowerShell. In this example, I’ll use a PowerShell step.

If you have a script already, you can click the Insert PowerShell Script link; otherwise, just enter the command into the PowerShell window.

Click Save when finished, and close the package editor window.
With the package saved, your command or script is ready to deploy to your devices whenever needed. When you’re ready, here’s how to deploy the package to your devices.
Select the package, then click Deploy Once.
Enter the names of your target computers, then click Add Computer.

With your targets added, click Deploy Now.
That’s it. You can add as many or as few devices as you want to a deployment, or target collections in PDQ Inventory to deploy to matching computers. For recurring tasks, create a PDQ Deploy schedule and use an Inventory collection as the target so the package runs automatically against devices that meet your criteria.
Running PowerShell commands on remote computers FAQs
What should you check if remote PowerShell commands fail?
If native PowerShell remoting fails, verify that WinRM is enabled and configured on the remote Windows computer, that the device is reachable, and that your account has the required permissions. PowerShell 6 and later can also use SSH for remoting.
When troubleshooting PDQ, check the deployment or command output in the applicable PDQ console. Also verify the execution context. For example, PDQ commands run in the local system context.
Can PDQ run remote commands on Windows and macOS devices?
Yes. PDQ lets admins run PowerShell or CMD commands on managed Windows devices and Bash or Zsh commands on managed macOS devices. Both Windows and macOS endpoints can be managed through the same agent-based PDQ platform.
How do you automate PowerShell tasks across multiple devices?
PDQ lets you automate PowerShell scripts across multiple Windows devices by adding scripts to custom packages, targeting devices or groups, and adding those packages to Automations. This lets admins use custom PowerShell workflows alongside software and patch deployments instead of relying only on predefined packages.
Run PowerShell scripts on remote devices
Execute PowerShell scripts on managed devices from anywhere with PDQ Connect.












