Skip to content

Instantly share code, notes, and snippets.

@juanje
Last active March 4, 2023 21:34
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save juanje/8496054 to your computer and use it in GitHub Desktop.
Save juanje/8496054 to your computer and use it in GitHub Desktop.
Batch script for activating the remote administration on Windows vía WinrRM
@ECHO ON
REM This batch script is almost identical to http://code.can.cd/winrm_setup.bat
REM To use this from powershell on windows in a one liner:
REM (New-Object System.Net.WebClient).DownloadFile('https://gist.github.com/juanje/8496054/raw/winrm_setup.bat','winrm_setup.bat') ; .\winrm_setup.bat
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig -transport:http
cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
cmd.exe /c netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
@ECHO Done.
@shadabkhan-sk
Copy link

Thank you. It is working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment