How to run PowerShell commands on a remote Windows 10 system
Windows 10 has remote access tools. These tools come built-in to the OS and you can also install third-party remote access tools. Remote access is a useful feature but it can also be a security risk if you do not take care how and when it’s enabled, or who you give remote access to. For this reason, most remote access tools are locked behind layers of access that must be granted before the tool can work on your system. PowerShell is no exception.
Run PowerShell commands on remote Windows 10 system
You can run PowerShell commands on a remote Windows 10 system but, the target system must allow these commands to be run remotely.
Enable PowerShell commands on remote system
To enable remote PowerShell commands to be run on a system, follow these steps.
- On the target system, open PowerShell with admin rights.
- Run this command:
Enable-PSRemoting -Force
- Once the command has been run, you will be able to access it remotely, and run PowerShell commands.
If the target computer is part of a workgroup but it is not connected to an Active Directory, you will need to enable PowerShell commands on the system by following these steps.
- On the target system, open PowerShell with admin rights.
- Run this command:
Set-NetFirewallRule -Name 'WINRM-HTTP-In-TCP' -RemoteAddress Any
- Once the command is run, you will be able to access the system remotely and run PowerShell commands on it.
These commands are basic when it comes to enabling PowerShell commands on a remote system but you will run other commands as well. For one, when you connect to a remote system, you will have to authenticate with the system’s username and password. Additionally, you will also have to whitelist the computer that you’re going to remotely access the system from. It is by no means a simple process but it starts by enabling commands to be run on the remote system.
Conclusion
Remote access is complicated when done through command lines. If you’re struggling to set up remote access, consider using a third-party tool like TeamViewer which is far easier to use but still secure. If you have no choice other than to use PowerShell, you should spend time learning how to initiate a connection, and parameters you can define for it. Do this before you need to remotely access the system. A little knowledge and insight into how remote access works will help you troubleshoot problems as they come up.