Skip to content

Instantly share code, notes, and snippets.

@deekayen
Created February 27, 2025 14:30
Show Gist options
  • Save deekayen/9f5b3f561572fa7cfc41bbd1ac99d26e to your computer and use it in GitHub Desktop.
Save deekayen/9f5b3f561572fa7cfc41bbd1ac99d26e to your computer and use it in GitHub Desktop.
Enable WinRM for Ansible using User Data in AWS
<powershell>
$url = "https://raw.githubusercontent.com/ansible/ansible-documentation/refs/heads/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$file = "$env:temp\ConfigureRemotingForAnsible.ps1"
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file -EnableCredSSP -CertValidityDays 3650 -ForceNewSSLCert
$Password = ConvertTo-SecureString "SETAREALPASSWORDHERE" -AsPlainText -Force
New-LocalUser "ansible_provision" -Password $Password -FullName "Ansible User" -Description "For running Ansible"
Add-LocalGroupMember -Group Administrators -Member ansible_provision
</powershell>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment