$currentIdentity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() $administratorRole = [Security.Principal.WindowsBuiltInRole]::Administrator if ($currentIdentity.IsInRole($administratorRole)) { Write-Host "Success: Running as administrator" -ForegroundColor green } else { Write-Host "Error: Not running as administrator" -ForegroundColor red Exit } Set-Variable ProgressPreference SilentlyContinue function Set-WorkingDirectory($path) { if (!(Test-Path -PathType Container $path)) { New-Item -ItemType Directory -Path $path } Set-Location $path } Set-WorkingDirectory "C:\ProgramData\Rauchmelder" # DO NOT include install-dotnet-runtime-9.0.4-win-x64.ps1 function Download($Url, $Filename, $Force = $False) { if ($Force -or !(Test-Path($Filename))) { Write-Host -NoNewline "Downloading $Filename... " Invoke-WebRequest $Url -OutFile $Filename Write-Host "OK" } } Download "https://feuerwehr.nockal.com/download/rauchmelder/windows/Rauchmelder.exe" "Rauchmelder.exe" $True ./Rauchmelder.exe interactive