How to enable PSRemoting to execute Powershell script from Remote Machine.


PSRemoting (PowerShell Remote execution) - PowerShell Remoting let you run PowerShell command or Access full PowerShell Session on remote Windows System. In other words, it's similar to SSH for accessing remote terminals from Remote computers.

PSRemoting disabled by default, you've to enable  PSRemoting before using it. 
Let's follow the process below to enable PSRemoting.


Prerequisites- 

  • Two Windows PC with Admin Rights.
  • One main PC that we will access remotely.
  • Another to Run and access PS of PC1.
Step 1- Enable PSRemoting (The PC will access Remotely) - Let's follow the steps below to enable PSRemoting.
  • Open PowerShell as an Administrator account.

  • In the Powershell Window, Run the following command and hit Enter key
Enable-PSRemoting -Force















This command starts the WinRM service, sets it to start automatically with your system, and creates a firewall rule that allows incoming connections. The -Force part of the cmdlet tells PowerShell to perform these actions without prompting you for each step.
If you're working on Domain network that is the process and you are ready to execute the Powershell command from the Remote PC.

Step 2- Follow the below process for Workgroup environment.
While you're working on homework or workgroup network then you have to trust your PC to connect remotely. 
Run the command below on the PC from where you would to like execute the commands.
Set-Item wsman:\localhost\client\trustedhosts *
The asterisk is a wildcard symbol for all PCs. If instead you want to restrict computers that can connect, you can replace the asterisk with a comma-separated list of IP addresses or computer names for approved PCs.

After running that command, you’ll need to restart the WinRM service so your new settings take effect. Type the following cmdlet and then hit Enter:

Restart-Service WinRM

All done, Now, you're ready to execute PowerShell script from a Remote computer.


Thank you very much for reading my Blog, Please comment below any suggestion or feedback to improve my Blog.