Enable PSRemoting Hands on: Configuration & troubleshooting

I have struggled to enable remote connection via PowerShell from really long time and it is frustrating to see you do everything right and you get error like

or

So, finally I set myself to just read first and then proceed step by step.

Firstly, you must do is read Microsoft about remote requirements but do not implement it as is because that would lead you to search issues like why New-PSSession does not connect etc. and you'd find that New-PSSession is to create remote session, however without any server name it usually connects to localhost.

Now implement following steps:

  1. Search & Run PowerShell as Administrator (aka elevated window)
  2. Find your system (for now, let's stick to remote connection to your own system: aka loopback) IP address by typing  
    • ipconfig
  3. Check your TrustedHosts list
    1. Get-Item WSMan:\localhost\Client\TrustedHosts
  4. Set your TrustedHosts list
    1. Set-Item WSMan:\localhost\Client\TrustedHosts -Value '<your IP address>'
  5. Then when you run Step 3 again, you should see
  6. Now, create a variable that stores Powershell session to this IP
    1. $session = New-PSSession -ComputerName <your IP address>
  7. Finally, remote login to your own system
    1. Enter-PSSession -Session $session 

In case you'd like to add more hosts to existing one, you can add concatenate parameter in Step 4

Set-Item WSMan:\localhost\Client\TrustedHosts -Value '<your new IP address>' -Concatenate

I hope you learned something new through this blog post. If so, your compliment in comments section would be highly appreciate. Not just that feel free to ask doubts in comment section. Also, I'd like to mention that ChatGPT did help in troubleshooting i.e., instead of reading several blogs, I prefer using ChatGPT to provide me concise information.

About Author:

profile image I am an IT Specialist and a Trainer who loves sharing knowledge in a simplified yet detailed step by step format. Through my live trainings I try to understand background of participants so I help them connect the dots. All my trainings are done through simplified real world examples. To know more, please visit my Linkedin profile.

Other useful links:




Comments

Popular posts from this blog

Case study: Active Directory

Generate learning path to become expert system administrator