#timeout=1000000 #!ps $version = 'DomainService_version_3.122x64server_Release' $PathRS = 'c:\Program Files\Ruffian Software' $SourceFile = "https://ruffiansoftware.com/wp-content/uploads/2023/02/DomainService_version_3.122x64server_Release.zip" $DestFile = "$PathRS\$version.zip" New-Item -ItemType Directory -Force -Path $PathRS if (Test-Path "$DestFile") { Remove-Item "$DestFile" # seems like we need to delay before overwritting a file we just deleted? Start-Sleep 2 } # some older systems have to be told what TLS to use because they default to 1.1 which is no longer supported [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -Uri "$SourceFile" -OutFile "$DestFile" if (Test-Path "$PathRS\$version\DomainService.exe") { start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist uninstall Remove-Item -Recurse -Force "$PathRS\$version" # seems like we need to delay before overwritting a file we just deleted? Start-Sleep 2 } # do a simple hash check to make sure we got a file that we are expecting. # This is only one of many ways we at Ruffian Software fight supply chain attacks. Everyone needs to do thier part. $hash = (Get-FileHash -Path "$DestFile").Hash if ($hash -ne "BB78E8A06F983893E3A79ADEEFD53184B59F4DD5E5B3DEBA945424552D048E2F") { Write-Error 'Hash of downloaded file does not match expected value.' -ErrorAction Stop } Expand-Archive -LiteralPath "$DestFile" -DestinationPath "$PathRS\$version" start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist update