Running a PowerShell command on a remote machine — by Michael Taylor on Microsoft Q&A
An accepted answer to how to run a locally-working command on other computers. It says to enable PowerShell remoting on the target first (on by default on servers, not on clients, and a security consideration), allow it through the firewall if not on a domain, then create a session with New-PSSession and run the script block with Invoke-Command.
Quick steps
- Enable remoting on the target machine
- Create a session with New-PSSession -ComputerName (add -Credential if needed)
- Run the code with Invoke-Command -Session $session -ScriptBlock { ... }
Paraphrased from the source. Menus can differ by version, so check the original for full details.
Source: Running a PowerShell command on a remote machine by Michael Taylor on Microsoft Q&A. Licence: Link only (©).
- Source reviewed
- 2026-11-02
- Link checked
- 2026-11-02
- Tested hands-on
- Not by Oddbyte.Me