Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99400fb03e | ||
|
|
ca115922bd | ||
|
|
082ae219b1 | ||
|
|
49b360dffa | ||
|
|
811025773e | ||
|
|
111d3bea66 | ||
|
|
4d780e900a |
@@ -2,20 +2,26 @@
|
||||
# Intune custom compliance discovery script for Linux: is Microsoft Defender
|
||||
# for Endpoint (mdatp) installed, onboarded, licensed and protecting?
|
||||
#
|
||||
# Upload in Intune > Devices > Compliance > Scripts (Linux), and pair it with
|
||||
# defender-compliance.json in a Linux compliance policy (Custom compliance).
|
||||
# Himmelblau runs it as root inside himmelblaud-tasks.service and sends the
|
||||
# JSON on stdout to Intune, which evaluates it against the rules. Every setting
|
||||
# is always emitted, so a missing or stopped Defender reads as non-compliant
|
||||
# instead of as a script error.
|
||||
# Upload in Intune > Endpoint security > Device compliance > Scripts (Linux),
|
||||
# and pair it with defender-compliance.json in a Linux compliance policy
|
||||
# (Custom compliance). Himmelblau runs it as root inside
|
||||
# himmelblaud-tasks.service and sends the JSON on stdout to Intune, which
|
||||
# evaluates it against the rules. Every setting is always emitted, so a missing
|
||||
# or stopped Defender reads as non-compliant instead of as a script error.
|
||||
|
||||
MDATP=/usr/bin/mdatp
|
||||
|
||||
# Print one `mdatp health` field without quotes or a trailing " [managed]".
|
||||
# Unlicensed or unonboarded, mdatp prints "ATTENTION: ..." lines first.
|
||||
# Defender won't answer `mdatp health` started from inside himmelblaud-tasks
|
||||
# (it can't read that process while checking the caller), so ask through
|
||||
# systemd, which runs mdatp as its own child. Elsewhere, ask mdatp directly.
|
||||
health="$(systemd-run --quiet --wait --pipe --collect "${MDATP}" health 2>/dev/null)"
|
||||
grep -q '^healthy' <<< "${health}" || health="$("${MDATP}" health 2>/dev/null)"
|
||||
|
||||
# Print one field of the `mdatp health` output ("name : value") without
|
||||
# quotes or a trailing " [managed]".
|
||||
field() {
|
||||
"${MDATP}" health --field "$1" 2>/dev/null | grep -v '^ATTENTION' | tail -n1 \
|
||||
| sed -e 's/ \[managed\]$//' -e 's/^"//' -e 's/"$//'
|
||||
grep -m1 "^$1 *:" <<< "${health}" \
|
||||
| sed -e 's/^[^:]*: *//' -e 's/ \[managed\]$//' -e 's/^"//' -e 's/"$//'
|
||||
}
|
||||
|
||||
bool() {
|
||||
|
||||
Reference in new issue
Block a user