Windows Classroom Series – 09/Oct/2020

Enabling Powershell Remoting using Win-RM

  • In enterprise setups we have domain controlled and it is easier to configure the windows remoting.
  • In this session, since we are trying to communicate over public networks, we would be making some tweaks
  • Create a Windows Server (2016). Launch Powershell as an admin\
Set-ExecutionPolicy RemoteSigned
Winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
  • Lets try to connect to winrm from Powershell on Client
$credential = Get-Credential qtdevops
Enter-PSSession -ComputerName <> -Credential $credential
  • The above command leads to error as we are communicated over public networks, if you try the same command b/w client & server connected in the same domain, you will not see this issue. Preview
  • To resolve this. Enter gpedit.msc in the run command
  • Now Navigate to Local Computer Policy => Computer Configuration => Administrative Templates => Windows Components => Windows Remote Management (winrm) => WinRM Client Preview
  • Enable Allow Basic Authentication & Allow unecrypted Traffic Preview
  • Now open Trusted Hosts and add the computer name of the server to trusted hosts Preview
  • Now Execute Enter-PSSession Cmdlet Preview
  • Now since the powershell terminal is connected to the other remote server, administration & execution of commands can be done from Powershell Terminal.

Powershell Scripts

  • For the first powershell script Refer Here
  • Ensure your Execution Policy is not Restricted
Get-ExecutionPolicy

Next Steps:

  1. We need to refine our scripting capabilities
  2. Create functions
  3. Accept Parameters
  4. Should be able do some administrative tasks.
  5. Active Directory

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin