MCM (SCCM/MECM)
Deploy and manage Safety Endpoint on Windows devices using Microsoft Configuration Manager Packages & Programs
Overview
Exit Code
Meaning
Prerequisites
Deploy Safety Endpoint
2
Prepare the Script
# Safety Endpoint - MDM Run Script (Windows)
# Template: values below are populated by the Safety Platform per organization.
# Paste this into your MDM script field (Intune, NinjaOne, etc.)
# Run as: SYSTEM | Schedule: recurring (e.g. every 1 hour)
#
# Downloads the Safety Endpoint setup script, verifies its Authenticode
# signature is from Safety CLI Cybersecurity Inc, and executes it.
# ── Organization Configuration ───────────────────────────────────────
$EnrollmentKey = "REPLACE_WITH_YOUR_ENROLLMENT_KEY"
# Comma-separated list of firewall tools to exclude (e.g. "pip,npm")
$ExcludeFirewallTools = ""
# ─────────────────────────────────────────────────────────────────────
$ErrorActionPreference = "Stop"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$setupUrl = "https://getsafety.com/cli/setup.ps1"
$tmpFile = Join-Path $env:TEMP "safety-mdm-setup-$(Get-Random).ps1"
# ── HttpClient with proxy support (same as install.ps1 / setup.ps1) ─
Add-Type -AssemblyName System.Net.Http -ErrorAction Stop
$handler = [System.Net.Http.HttpClientHandler]::new()
$proxyUrl = @($env:HTTPS_PROXY, $env:ALL_PROXY, $env:HTTP_PROXY) |
Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | Select-Object -First 1
if ($proxyUrl) {
$proxyUri = [Uri]$proxyUrl
$proxy = New-Object Net.WebProxy($proxyUri)
if ($proxyUri.UserInfo) {
$parts = $proxyUri.UserInfo -split ":", 2
$proxy.Credentials = New-Object Net.NetworkCredential(
[Uri]::UnescapeDataString($parts[0]),
$(if ($parts.Length -gt 1) { [Uri]::UnescapeDataString($parts[1]) } else { "" })
)
} else {
$proxy.UseDefaultCredentials = $true
}
$handler.Proxy = $proxy
} else {
$handler.DefaultProxyCredentials = [Net.CredentialCache]::DefaultCredentials
}
$client = [System.Net.Http.HttpClient]::new($handler)
$null = $client.DefaultRequestHeaders.UserAgent.ParseAdd("Safety-Endpoint/1 (run)")
# ── Download, verify, execute ────────────────────────────────────────
try {
# 1. Download (preserves exact bytes for Authenticode)
Write-Host "Downloading $setupUrl ..."
$response = $client.GetAsync($setupUrl).GetAwaiter().GetResult()
$null = $response.EnsureSuccessStatusCode()
$bytes = $response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult()
[System.IO.File]::WriteAllBytes($tmpFile, $bytes)
# 2. Verify Authenticode signature
$sig = Get-AuthenticodeSignature -FilePath $tmpFile
if ($sig.Status -ne "Valid") {
throw "Signature status: $($sig.Status) - $($sig.StatusMessage)"
}
if ($sig.SignerCertificate.Subject -notmatch "O=Safety CLI Cybersecurity Inc") {
throw "Unexpected signer: $($sig.SignerCertificate.Subject)"
}
Write-Host "Signature verified: $($sig.SignerCertificate.Subject)"
# 3. Execute
$setupArgs = @{ EnrollmentKey = $EnrollmentKey }
if ($ExcludeFirewallTools) { $setupArgs.ExcludeFirewallTools = $ExcludeFirewallTools }
& $tmpFile @setupArgs
}
catch {
Write-Error "Safety MDM setup failed: $_"
exit 1
}
finally {
Remove-Item $tmpFile -Force -ErrorAction SilentlyContinue
if ($client) { $client.Dispose() }
}Monitor Deployments
Status
What It Means
Action
Uninstall Safety Endpoint
Troubleshooting
Last updated
Was this helpful?

