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 f699a6c182e8f071e220c22762658564ec233a46

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
3
4"C:\Program Files\PowerShell\7\pwsh" -Command "Invoke-WebRequest https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.11-I601-Win10.exe -OutFile c:\openvpn-setup.exe"
5c:\openvpn-setup.exe /S
6"C:\Program Files\PowerShell\7\pwsh" -Command "set-service -name OpenVPNService -StartupType Automatic"
7net start OpenVPNService
8netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp localport=3389
9
10"C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"
11"C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force"
12netsh advfirewall firewall add rule name="22" dir=in action=allow protocol=tcp localport=22
13set authkeysurl=
14"C:\Program Files\PowerShell\7\pwsh" -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys"
15rem https://superuser.com/a/1605117
16"C:\Program Files\PowerShell\7\pwsh" -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"
17net start sshd
18"C:\Program Files\PowerShell\7\pwsh" -Command "set-service -name sshd -StartupType Automatic"
19
20"C:\Program Files\PowerShell\7\pwsh" -Command "iwr -useb get.scoop.sh | iex; scoop install git; scoop update; scoop bucket add extras; scoop install chromium rclone"