Remotely turning on remote PowerShell commands

In my last post I gave a Powershell command that accesses the registry. Doing this for a remote PC requires that the PowerShell command be run on the remote PC. This requires remote PowerShell to be enabled, which it is on Windows 7.

To turn it on, you use the PowerShell command Enable-PsRemoting -Force

However, you can run this on a remote Powershell session until you enable remote PowerShell sessions. Catch-22.

To turn it on, I used the code here.

The script basically uses Task Scheduler to create a task on the remote PC that runs the Enable-PsRemoting command and then deletes the task.

Once this is done, you can run a remote PowerShell session with this command:

Enter-PSSession -ComputerName remotepc

Leave a Reply

Your email address will not be published. Required fields are marked *