You are on page 1of 4

Remote PowerShell Connection Setup.

chat.openai.com/chat/ad1933d8-2126-4fc4-a1d8-fb569f7bccb1

danw.ca@gmail.com
provide instruction to show how to setup a connect with a remote powershell

Sure, here are the steps to set up a remote PowerShell connection:

1. Enable PowerShell remoting on the remote machine

Open PowerShell on the remote machine with Administrator privileges


Run the command: Enable-PSRemoting -Force
2. Check if the WinRM service is running on the remote machine

Open the Windows Services console on the remote machine


Look for the Windows Remote Management (WinRM) service
If the service is not running, start it and set it to start automatically
3. Allow PowerShell traffic through the Windows Firewall on the remote machine

Open Windows Firewall on the remote machine


Add an inbound rule to allow traffic on TCP port 5985 (for HTTP) or 5986
(for HTTPS)
4. Configure the client machine to connect to the remote machine

Open PowerShell on the client machine with Administrator privileges


Run the command: Set-Item
WSMan:\localhost\Client\TrustedHosts -Value "<remote-
computer-name>" -Force
Replace <remote-computer-name> with the name or IP address of the
remote machine

1/4
5. Connect to the remote machine from the client machine

Open PowerShell on the client machine


Run the command: Enter-PSSession -ComputerName <remote-
computer-name> -Credential <username>
Replace <remote-computer-name> with the name or IP address of the
remote machine
Replace <username> with a username that has administrative privileges
on the remote machine
You will be prompted to enter the password for the specified username
6. Once you're connected to the remote machine, you can execute PowerShell
commands and scripts as if you were working directly on the remote machine.

Note: Make sure that the client machine and the remote machine are on the same
network and that you have the necessary permissions to connect to the remote
machine. Also, consider using HTTPS instead of HTTP for increased security.

danw.ca@gmail.com
WinRM firewall exception will not work since one of the network connection types on
this machine is set to Public. Change the network connection type to either Domain or
Private and try again.

If you receive this error message while trying to configure a WinRM firewall exception,
it means that your current network connection type is set to Public, which is a less
trusted network profile. WinRM firewall exception is not enabled by default on Public
networks to prevent unauthorized access.

To resolve this issue, you can change the network connection type to either Domain or
Private, which are more trusted network profiles. Follow these steps:

1. Open the Control Panel on your computer.


2. Click on "Network and Sharing Center."
3. Click on "Change adapter settings" on the left-hand side.
4. Right-click on the network connection you are using and select "Properties."
5. Select "Private" or "Domain" for the network profile instead of "Public."
6. Click "OK" to save the changes.

2/4
Once you've changed the network connection type, try configuring the WinRM firewall
exception again. This should allow you to connect to the remote machine using
PowerShell remoting.

danw.ca@gmail.com
Set-Item : Cannot find drive. A drive with the name 'WSMan' does not exist.
At line:1
char:1
+ Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.2.14" - ...

If you receive this error message while trying to set the TrustedHosts value for a
remote PowerShell connection, it means that the WSMan PSDrive is not loaded in
your PowerShell session. The WSMan PSDrive is required to manage WinRM settings.

To load the WSMan PSDrive, run the following command in your PowerShell session:

sql

Import-Module -Name Microsoft.WSMan.Management

Once you've loaded the WSMan PSDrive, you can set the TrustedHosts value using the
Set-Item cmdlet. For example, if you want to set the TrustedHosts value to allow
connections from a remote machine with the IP address of "192.168.2.14", run the
following command:

python

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.2.14" -


Force

This will add "192.168.2.14" to the list of trusted hosts for your local machine, allowing
you to connect to it using PowerShell remoting.

3/4

4/4

You might also like