-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDRMM-WIN-IntuneScript.ps1
More file actions
42 lines (36 loc) · 1.69 KB
/
DRMM-WIN-IntuneScript.ps1
File metadata and controls
42 lines (36 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$Platform = "syrah"
$SiteID = "16a4c08f-38c1-4c2e-b1dc-77b18a1f8c21"
<#
Datto RMM Agent deploy by MS Azure Intune
Designed and written by Jon North, Datto, March 2020
Download the Agent installer, run it, wait for it to finish, delete it
#>
# First check if Agent is installed and instantly exit if so
If (Get-Service CagService -ErrorAction SilentlyContinue) {
Write-Output "Datto RMM Agent already installed on this device"
exit
}
# Download the Agent
$AgentURL = "https://$Platform.rmm.datto.com/download-agent/windows/$SiteID"
$DownloadStart = Get-Date
Write-Output "Starting Agent download at $(Get-Date -Format HH:mm) from $AgentURL"
try {
[Net.ServicePointManager]::SecurityProtocol=[Enum]::ToObject([Net.SecurityProtocolType],3072)
} catch {
Write-Output "Cannot download Agent due to invalid security protocol. The`r`nfollowing security protocols are installed and available:`r`n$([enum]::GetNames([Net.SecurityProtocolType]))`r`nAgent download requires at least TLS 1.2 to succeed.`r`nPlease install TLS 1.2 and rerun the script."
exit 1
}
try {
(New-Object System.Net.WebClient).DownloadFile($AgentURL, "$env:TEMP\DRMMSetup.exe")
} catch {
$host.ui.WriteErrorLine("Agent installer download failed. Exit message:`r`n$_")
exit 1
}
Write-Output "Agent download completed in $((Get-Date).Subtract($DownloadStart).Seconds) seconds`r`n`r`n"
# Install the Agent
$InstallStart = Get-Date
Write-Output "Starting Agent install to target site at $(Get-Date -Format HH:mm)..."
& "$env:TEMP\DRMMSetup.exe" | Out-Null
Write-Output "Agent install completed at $(Get-Date -Format HH:mm) in $((Get-Date).Subtract($InstallStart).Seconds) seconds."
Remove-Item "$env:TEMP\DRMMSetup.exe" -Force
Exit