Skip to content

How to run PowerShell commands on remote computers

Brock
Brock Bingham|Updated September 3, 2026
Dog drooling while reading content on laptop
Dog drooling while reading content on laptop

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>
PowerShell console using Enter-PSSession to connect to the remote computer AANG.

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.

PowerShell comparing local and remote C drive information after connecting with Enter-PSSession.

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>
PowerShell creating a persistent remote session to AANG with New-PSSession.

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>
PowerShell entering the Runspace1 remote session with Enter-PSSession and verifying the computer name AANG.

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>
PowerShell creating persistent sessions to AANG, TOPH, and KATARA with New-PSSession.

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 running Get-PSDrive against three remote PowerShell sessions.

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}
Invoke-Command checking the Windows edition on remote computers AANG, TOPH, and KATARA.

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.

PDQ device page with the Commands tool selected for running remote commands.

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.

PDQ Commands console running Get-WindowsOptionalFeature on a remote Windows device.

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.

  1. In PDQ, click the Packages tab.

  2. Click Create package.

    PDQ Packages page with the Create package button highlighted.

  3. Name the package.

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

    PDQ package editor showing the Add script step option for a custom package.

  5. Set the script type, either PowerShell or CMD. I’ll use a CMD command for this example.

  6. Click the Import link to import a script, or type your command into the scripting pane.

    PDQ custom package with a CMD script step running GPUpdate /Force.

  7. 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.

PDQ deployment window targeting a custom package to the device IROH.

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.

PDQ Deployments page showing completed remote command deployments.
PDQ deployment output showing a successful Group Policy update command.

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.

  1. In PDQ Inventory, select a computer (or multiple computers).

  2. Right-click on the selection, then click Tools, then click Run Command.

    PDQ Inventory Tools menu with Run Command selected for remote computers.

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

    PDQ Inventory Run Command window running gpupdate /force against remote computers.

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

PDQ Inventory Run Command window displaying ipconfig results from a remote computer.

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.

PDQ Inventory Run Command window running Get-Process with remote execution options displayed.

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.

  1. In PDQ Deploy, click the New Package button.

  2. Enter a name for the package, then click New Step > Command or New Step > PowerShell. In this example, I’ll use a PowerShell step.

    PDQ Deploy package editor with Command and PowerShell step options highlighted.

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

    PDQ Deploy PowerShell step running the Register-DnsClient command.

  4. 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.

  1. Select the package, then click Deploy Once.

  2. Enter the names of your target computers, then click Add Computer.

    PDQ Deploy Once window targeting the AANG and TOPH computers for deployment.

  3. 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.

ConnectIcon CTA

Run PowerShell scripts on remote devices

Execute PowerShell scripts on managed devices from anywhere with PDQ Connect.

Brock
Brock Bingham

Brock Bingham is a systems administrator with 15 years of experience managing endpoints and servers, with a strong focus on automation, patching, security, and maintaining stable environments at scale. After years of hands-on IT work, he now creates content and teaches, helping other admins learn through practical, real-world guidance.

Related articles