-
-
Save bentman/638c478ae791598780c70749139e382f to your computer and use it in GitHub Desktop.
<# | |
.SYNOPSIS | |
Script to install Dev Tools on Windows Server (tested on 2022) | |
.DESCRIPTION | |
Installs the following from multiple resources: | |
Microsoft.VCLibs v14.00 (github) | |
Microsoft.UI v2.8.6 (github) | |
winget-cli (dynamic version retrieval from api.github.com) | |
Microsoft.WindowsTerminal (dynamic version retrieval from api.github.com) | |
Microsoft pwsh.exe vCurrent (winget) | |
Microsoft VSCode vCurrent (winget) | |
Azure CLI vCurrent (PoSh/MSI) | |
.NOTES | |
Add-DevToMyWinServer.ps1 | |
Version: 1.4 | |
Creation Date: 2024-05-04 | |
Copyright (c) 2023 https://github.com/bentman | |
#> | |
# Install NuGet (no-prompt) & set PSGallery trusted | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
Push-Location ~\Downloads | |
# From Microsoft.VCLibs redirect | |
$MsftVc_Link = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx' | |
$MsftVc_Name = 'Microsoft.VCLibs.x64.14.00.Desktop.appx' | |
Invoke-WebRequest -Uri $MsftVc_Link -OutFile .\$MsftVc_Name -Verbose | |
Add-AppPackage -Path .\$MsftVc_Name -Verbose | |
# From github Microsoft.UI.Xaml https://github.com/microsoft/microsoft-ui-xaml/releases | |
$MsftUi_Link = 'https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx' | |
$MsftUi_Name = 'Microsoft.UI.Xaml.2.8.x64.appx' | |
Invoke-WebRequest -Uri $MsftUi_Link -OutFile .\$MsftUi_Name -Verbose | |
Add-AppPackage -Path .\$MsftUi_Name -Verbose | |
# MSFT WinGet from winget-cli https://api.github.com/repos/microsoft/winget-cli/releases/latest | |
$winGet_Repo = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" | |
$licXml_Link = (Invoke-WebRequest -Uri $winGet_Repo).Content | | |
ConvertFrom-Json | | |
Select-Object -ExpandProperty "assets" | | |
Where-Object "browser_download_url" -Match '_License1.xml' | | |
Select-Object -ExpandProperty "browser_download_url" | |
$LicXml_Name = '_License1.xml' | |
Invoke-WebRequest -Uri $licXml_Link -OutFile $LicXml_Name -UseBasicParsing | |
Unblock-File .\$LicXml_Name | |
$winGet_Link = (Invoke-WebRequest -Uri $winGet_Repo).Content | | |
ConvertFrom-Json | | |
Select-Object -ExpandProperty "assets" | | |
Where-Object "browser_download_url" -Match '.msixbundle' | | |
Select-Object -ExpandProperty "browser_download_url" | |
$winGet_Name = "winget.msixbundle" | |
Invoke-WebRequest -Uri $winGet_Link -OutFile $winGet_Name -UseBasicParsing | |
Unblock-File .\$winGet_Name | |
Add-AppxProvisionedPackage -Online -PackagePath .\$winGet_Name -LicensePath .\$LicXml_Name -Verbose | |
# MSFT Terminal from https://api.github.com/repos/microsoft/terminal/releases/latest | |
$term_Repo = "https://api.github.com/repos/microsoft/terminal/releases/latest" | |
$term_Link = (Invoke-WebRequest -Uri $term_Repo).Content | | |
ConvertFrom-Json | | |
Select-Object -ExpandProperty "assets" | | |
Where-Object "browser_download_url" -NotMatch '.zip' | | |
Select-Object -ExpandProperty "browser_download_url" | |
$term_Name = 'WindowsTerminal.msixbundle' | |
Invoke-WebRequest -Uri $term_Link -OutFile .\$term_Name -Verbose | |
Unblock-File .\$term_Name | |
Add-AppPackage -Path .\$term_Name -Verbose | |
Pop-Location | |
################################################ | |
### NOTE: This now requires shell restart!!! ### | |
################################################ | |
# WinGet look for pwsh.exe versions (may prompt to accept terms) | |
winget search Microsoft.PowerShell | |
# Install pwsh.exe from winget | |
winget install --id Microsoft.Powershell --source winget | |
# WinGet look for VS Code versions (it may prompt to accept terms) | |
winget search Microsoft.VisualStudioCode | |
# Install VS Code from winget | |
winget install --id Microsoft.VisualStudioCode --source winget | |
# WinGet look for AzureCLI (it may prompt to accept terms) | |
winget search Microsoft.AzureCLI | |
# Install AzureCLI from winget | |
winget install --id Microsoft.AzureCLI --source winget | |
winget update --all | |
### Install OpenSSH ### | |
# Install the OpenSSH Client | |
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 | |
# Install the OpenSSH Server | |
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | |
# Start SSH Server Service | |
Get-Service sshd | Start-Service | |
# Set SSH Server Service | |
Set-Service -Name sshd -StartupType 'Automatic' | |
# Enforce SSH Firewall rule configuration | |
$sshFw = Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ea 0 | Select-Object Name | |
if ($null -eq $sshFw) { | |
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 | |
} | |
if ($false -eq ($sshFw).enabled) { | |
Set-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 | |
} | |
# SSH Default Shell powershell.exe | |
# New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force | |
# SSH Default Shell pwsh.exe | |
New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value '"C:\Program Files\PowerShell\7\pwsh.exe"' -PropertyType String -Force | |
# Disable NLA on RDP | |
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'UserAuthentication' -Value 0 | |
# |
VERBOSE: GET https://github.com/microsoft/terminal/releases/download/v1.19.11213.0/Microsoft.WindowsTerminal_1.19.11213.0_8wekyb3d8bbwe.msixbundle with 0-byte payload
VERBOSE: received 21550188-byte response of content type application/octet-stream
VERBOSE: Performing the operation "Deploy package" on target "D:\Microsoft.WindowsTerminal_1.19.11213.0_8wekyb3d8bbwe.msixbundle".
Add-AppPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates, dependency or conflict validation.
Windows cannot install package Microsoft.WindowsTerminal_1.19.11213.0_x64__8wekyb3d8bbwe because this package depends on a framework that could not be found. Provide the framework "Microsoft.UI.Xaml.2.8" published by "CN=Microsof
t Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor architecture and minimum version 8.2305.5001.0, along with this package to install. The frameworks with name "Microsoft.UI.Xaml
.2.8" currently installed are: {}
fail on Windows Server 2022
should upgrade to 2.8:
$MsftUi_Link = 'https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx'
> fail on Windows Server 2022
should upgrade to 2.8:
$MsftUi_Link = 'https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx'
yup. looking for a way to do them all more 'dynamically' (aka - query the latest version to download). i'll update the static until then. thanks!
Updated dynamic version retrieval...
winget-cli (api.github.com)
Microsoft.WindowsTerminal (api.github.com)
Updated versions...
winget-cli v1.7.11132 (github)
Microsoft.WindowsTerminal v1.19.11213.0 (github)