#timeout=1000000 #!ps # to run this script set these values correctly $ClientGuid = 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy' $RMMName = $null # $RMMName = 'put some RMM name here' $FriendlyName = $null # $FriendlyName = 'put some friendly name here' $OU = $null # $OU = 'TechIDManager.AdminUsers' # check the ClientGuid to make sure it is set. It is the only one that must be set. if ($ClientGuid -eq 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy' -or $ClientGuid -eq '' -or $ClientGuid -eq $null ) { Write-Error '$ClientGuid needs to be set' -ErrorAction Stop } $version = 'DomainService_version_3.156x64server_Release' $PathRS = 'c:\Program Files\Ruffian Software' $SourceFile = "https://ruffiansoftware.com/wp-content/uploads/2023/04/DomainService_version_3.156x64server_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 # if your systems are up to date, then you do not need the following line. [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 their part. $hash = (Get-FileHash -Path "$DestFile").Hash if ($hash -ne "04799CAE168F6C91DCA2B8668BEDC936223F5933A2AFF91282A9F5C82443FF8A") { Write-Error 'Hash of downloaded file does not match expected value.' -ErrorAction Stop } Expand-Archive -LiteralPath "$DestFile" -DestinationPath "$PathRS\$version" if ($OU -ne $null ) { start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist @("ou", '"' + $OU + '"') } if ($FriendlyName -ne $null ) { start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist @("friendlyname", '"' + $FriendlyName + '"') } if ($RMMName -ne $null ) { start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist @("rmmname", '"' + $RMMName + '"') } # you can add other parameter setting here..... # note the escaping of argumentlists in powershell as above with '"' + ... + '"' around arguments with spaces in them start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist @("clientid", "$ClientGuid") start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist install start-process -nonewwindow -wait "$PathRS\$version\DomainService.exe" -argumentlist start