Closed raymix closed 1 year ago
Hey,
I had the same issue and fixed it as following:
detection.sh (output has to be JSON format)
... echo '{"testVar": "True"}' ...
rules.json
... "DataType":"String", "Operand":"True", ....
And i agree, the logging is really bad.
EDIT 13/02/2023: Microsoft has added official code examples last week, that are well explained.
@AdminOf: Thanks for your input, works after replacing comma with colon in bash output Also, I completely forgot to install MS Edge, which was a mandatory requirement... and probably cause me to miss that during many trials and errors. Thankfully we are not limited to using single quotes with echo, meaning that output can be efficiently generated using variables instead.
Prerequisites: Microsoft Intune and MS Edge: https://github.com/microsoft/shell-intune-samples/blob/master/Linux/Misc/Enrollment%20Prep%20Script/LinuxIntuneEnrollmentPrep.sh
Limitations:
null
variables in title or description, make sure MS Edge is installednull
, please remember that scripts run in much older #!/bin/dash
or "POSIX-compatible" environment. Functions, arrays or appending do not work the same way it does in bash, so do yourself a favor and get shellcheck. It comes as a VSCode extension, if you're on Windows.detection.sh
#!/bin/dash
#set +x
serviceStatus1="Running"
serviceStatus2="Not running"
serviceStatus3="Missing"
(
set -e
echo "{\"Service1\":\"$serviceStatus1\",\"Service2\":\"$serviceStatus2\",\"Service3\":\"$serviceStatus3\"}"
)
rules.json
{
"Rules":[
{
"SettingName":"Service1",
"Operator":"IsEquals",
"DataType":"String",
"Operand":"Running",
"MoreInfoUrl":"https://bing.com",
"RemediationStrings":[
{
"Language": "en_US",
"Title": "Service1: {ActualValue}",
"Description": "Please contact IT to resolve"
}
]
},
{
"SettingName":"Service2",
"Operator":"IsEquals",
"DataType":"String",
"Operand":"Running",
"MoreInfoUrl":"https://bing.com",
"RemediationStrings":[
{
"Language": "en_US",
"Title": "Service2: {ActualValue}",
"Description": "Please contact IT to resolve"
}
]
},
{
"SettingName":"Service3",
"Operator":"IsEquals",
"DataType":"String",
"Operand":"Running",
"MoreInfoUrl":"https://bing.com",
"RemediationStrings":[
{
"Language": "en_US",
"Title": "Service3: {ActualValue}",
"Description": "Service is {ActualValue}!\nPlease run below command to resolve this:\n\nsudo apt install -y fortune && fortune"
}
]
}
]
}
Screenshot:
Hi folks
I noticed you guys have some Linux script samples uploaded here, so I am hoping you can shed some light. I've spent hours on this issue, but can't figure out how to get custom compliance script working on Ubuntu 20.04.
I found some logs for Intune app under
/var/log/syslog
but its output is not helpful. Tried following your script example, but the Intune app returns null values, what am I missing here?detection.sh
rules.json
result:![image](https://user-images.githubusercontent.com/7531643/208647661-0c782301-976d-4a50-af35-d36a5b764705.png)