Skip to content

TargetProcess/onpremise_ansible-winrm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Controlling WinRM for Windows Hosts

Before executing Ansible playbook WinRM should be enabled on Windows Hosts.
All script should be executed using elevated Powershell session (Run as Administrator).

Enable and Setup WinRM

To Enable WinRM, please run script Setup-WinRM.ps1 and pass -username <userName> and -password parameters with Administrator priviliges.

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

$url = "https://raw.githubusercontent.com/TargetProcess/onpremise_ansible-winrm/refs/heads/master/scripts/Setup-WinRM.ps1"
$file = "$env:temp\Setup-WinRM.ps1"

(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file -username <Username> -password <Password>

Disable WinRM

To Disable WinRM, please run script Disable-WinRM.ps1 with Administrator priviliges.

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

$url = "https://gitlab.tpondemand.net/onpremise/ansible-winrm/-/raw/master/scripts/Disable-WinRM.ps1"
$file = "$env:temp\Disable-WinRM.ps1"

(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file

Disable-WinRM.ps1 script will:

  1. Remove HTTPS and HTTP Listeners
  2. Remove Firewall rules for HTTPS (Leave HTTP as it’s system default)
  3. Disable PS Remoting
  4. Disable CredSSP authentication
  5. Stop and Disable WinRM service
  6. Set LocalAccountTokenFilterPolicy to 0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published