-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintune_macos_s1registration,sh
44 lines (36 loc) · 1.46 KB
/
intune_macos_s1registration,sh
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
43
44
!/bin/bash
# SentinelOne agent registration script in the default group.
# Script by Patrick Gagne & Andre Laplante.
# Date: 14 sept 2023
# Ver 0.1
# Put your Sentinel one group token information on the line #23
# Run the sentinelctl status command and store the output in a variable
if [ -e /usr/local/bin/sentinelctl ]; then
status_output=$(/usr/local/bin/sentinelctl status)
else
echo "Sentinel One agent is not installed."
Exit 127
fi
# Get the output code of the previous command
status_code=$?
# Check whether the output contains a specific value
if [[ "$status_output" != *"https://usea1-015.sentinelone.net"* ]]; then
# If the value is not present, run the command sentinelctl set registration-token
/usr/local/bin/sentinelctl set registration-token -- "PUT_YOUR_GROUP_TOKEN_HERE"
# Get the output code of the previous command
set_token_status_code=$?
if [ $set_token_status_code -eq 0 ]; then
echo "The sentinelctl set registration-token command has been executed successfully."
exit $set_token_status_code
else
echo "The sentinelctl set registration-token command failed with the output code: $set_token_status_code"
exit $set_token_status_code
fi
fi
if [ $status_code -eq 0 ]; then
echo "The required value is present in the sentinelctl status output. No action required."
exit 0
else
echo "The sentinelctl status command failed with the exit code : $status_code"
exit $status_code
fi