Last active 1619348060

A windows startup cmd script, and bash script to execute it on vultr. installs all the things i think are useful to have on a new windows server

Revision ca9601fb94069bb5eae414b4b584aca0d527fad5

windows-init.bat Raw
1powershell -Command "iwr https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x64.msi -OutFile c:\powershell.msi"
2msiexec /i c:\powershell.msi /quiet
3set path="C:\Program Files\PowerShell\7\;%path%"
4
5pwsh -Command "Invoke-WebRequest https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.11-I601-Win10.exe -OutFile c:\openvpn-setup.exe"
6c:\openvpn-setup.exe /S
7pwsh -Command "set-service -name OpenVPNService -StartupType Automatic"
8net start OpenVPNService
9netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp localport=3389
10
11pwsh -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"
12pwsh -Command "Install-Module -Force OpenSSHUtils -Scope AllUsers"
13pwsh -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force"
14net start sshd
15net stop sshd
16pwsh -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config"
17pwsh -Command "echo 'PubkeyAuthentication yes' >> c:\programdata\ssh\sshd_config"
18pwsh -Command "echo 'PasswordAuthentication no' >> c:\programdata\ssh\sshd_config"
19net start sshd
20netsh advfirewall firewall add rule name="vpn 22" dir=in action=allow protocol=tcp localport=22
21set authkeysurl=
22pwsh -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys"
23rem https://superuser.com/a/1605117
24pwsh -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl"
25
26pwsh -Command "iwr -useb get.scoop.sh | iex"
27pwsh -Command "scoop install git"
28pwsh -Command "scoop update"
29pwsh -Command "scoop bucket add extras"
30pwsh -Command "scoop install chromium rclone"