-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare-windows.ps1
executable file
·38 lines (30 loc) · 1.69 KB
/
prepare-windows.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
###############
# Install WSL2 distro
###############
Write-Host "Install WSL2 + Ubuntu 22.04`r`n"
wsl.exe --install -d 'Ubuntu-22.04'
wsl.exe --set-default 'Ubuntu-22.04'
###############
# Enable WinRM Windows service with CredSSP authentication, disable Basic Auth
###############
Write-Host "Enabling WinRM (if you don't need it, you can disable it after applying the playbooks)`r`n"
winrm quickconfig
#[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
Invoke-Webrequest $url -OutFile ${env:USERPROFILE}\AnsibleWinrmConfig.ps1 -Verbose
sleep 2
Set-ExecutionPolicy Bypass -Scope Process -Force; ${env:USERPROFILE}\AnsibleWinrmConfig.ps1 -EnableCredSSP -DisableBasicAuth -Verbose
Enable-WSManCredSSP -Role Server -Force
Write-Host "`r`n`r`n"
Write-Host "To verify if WINRM got configured properly:`r`n"
Write-Host " - check if https listener port 5986 is open: winrm enumerate winrm/config/Listener`r`n"
Write-Host " - check service if CredSSP is active: winrm get winrm/config/Service`r`n"
###############
# Install Chocolatey
###############
Write-Host "Installing Chocolatey package manager`r`n"
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
###############
# Finish
###############
Write-Host "`r`n`r`nDone! To finalize the setup, clone this repository into your WSL and continue from there.`r`nRefer to README for step by step instructions or details."