Installing SQL Server Express on Windows 2022 Azure Pipelines is easy.
Here is my code:
function Test-IsAdmin {
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (-not (Test-IsAdmin)) {
Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File", "`"$PSCommandPath`"" -Verb RunAs
exit
}
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
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'))
}
choco install sql-server-express -y
This works fine! However, what do I need to change in my PowerShell code to install SQL Server Developer edition (2019).
This will be very useful for my integration tests. I did not find a choco package so I need another way. Keep in mind it needs to run in Azure Pipelines, not just on a windows 11 laptop or so (which has nice tooling such as winget).