Created
May 26, 2023 07:19
-
-
Save ducke/f55f592e27bc75c4ed5f2609a7c45aa3 to your computer and use it in GitHub Desktop.
Win Ansible Lab Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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