Skip to content

Instantly share code, notes, and snippets.

@ducke
Created May 26, 2023 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducke/f55f592e27bc75c4ed5f2609a7c45aa3 to your computer and use it in GitHub Desktop.
Save ducke/f55f592e27bc75c4ed5f2609a7c45aa3 to your computer and use it in GitHub Desktop.
Win Ansible Lab Setup
$username = "ansible"
$password = ConvertTo-SecureString "1234QWer" -AsPlainText -Force
try {
Get-LocalUser -Name $username -ErrorAction Stop
}
catch {
New-LocalUser -Name $username -Password $password -FullName $username -Description $username -PasswordNeverExpires
}
try {
Get-LocalGroupMember -Group Administrators -Member $username -ErrorAction Stop
}
catch {
Add-LocalGroupMember -Group Administrators -Member $username
}
iex ((New-Object System.Net.WebClient).DownloadString('http://10.0.100.100/winrm.ps1'))
if (!(Get-Item -Path WSMan:\localhost\Service\Auth\Basic).Value) {
Set-Item -Path WSMan:\localhost\Service\Auth\Basic -Value $true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment