using assembly System.Net.Http using namespace System.Net.Http # THIS NEEDS TO BE RUN AS ADMIN/SYSTEM # NEED TO Set-ExecutionPolicy -ExecutionPolicy Unrestricted...... FIRST! # Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine -Force # Set the source and destination. From sharepoint online, MAKE SURE YOU HAVE &download=1 AT THE END OF THE URL $source = 'Input cloud source here (URL)' $destination = Join-Path $env:temp '\agent.zip' # Prompt for credentials # $credentials = Get-Credential # Create the HTTP client download request with optional credentials $handler = New-Object System.Net.Http.HttpClientHandler # $handler.Credentials = $credentials $httpClient = New-Object System.Net.Http.HttpClient($handler) $response = $httpClient.GetAsync($source) $response.Wait() # Create a file stream to pointed to the output file destination $outputFileStream = [System.IO.FileStream]::new($destination, [System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::Write) # Stream the download to the destination file stream $downloadTask = $response.Result.Content.CopyToAsync($outputFileStream) $downloadTask.Wait() # Close the file stream $outputFileStream.Close() # Unzip the agent zip into %temp% Expand-Archive -Force -LiteralPath $destination -DestinationPath $env:temp # Create needed folder mkdir "C:\ProgramData\Barracuda RMM\Device Manager\Setup" # Run the setup $installMSI = Join-Path $env:temp '\Common\DMInstaller.msi' $installMSILog = Join-Path $env:temp '\DMInstaller_xml.log' # Run the setup $installMSI = Join-Path $env:temp '\Common\DMInstaller.msi' $installMSILog = Join-Path $env:temp '\DMInstaller_xml.log' $MSIArguments = @( "/i" $installMSI "/qn" "/norestart" "/l*v" $installMSILog ) Start-Process msiexec.exe -Wait -ArgumentList $MSIArguments -NoNewWindow