-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathCheck Printer Install.sh
42 lines (36 loc) · 1.3 KB
/
Check Printer Install.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
#!/bin/zsh
#####################################################################################
#
# Printer Validation
# for
# Setup Your Mac via swiftDialog
#
####################################################################################
#
# HISTORY
#
# Version 0.0.1, 25-Apr-2023, @drtaru
# - Original Version
#
# Version 0.0.2, 25-Apr-2023, @drtaru
# - Changed success result to Installed to map to new SYM validation status
#
####################################################################################
# A script to find printers with lpstat and build an array
#
# To get possible values for the script run the following on a machine that only
# has the desired printers added via the same method as your jamf policies
#
# lpstat -p 2>/dev/null | awk '{print $2}' | sed '/^$/d'
#
####################################################################################
foundPrinters=($(lpstat -p 2>/dev/null | awk '{print $2}' | sed '/^$/d'))
# Place the resulting values from your lpstat command in the =~ "" blocks
# You can add as many || or commands as needed to match expected printers
#
# NOTE: If any printer is missing the entire validation will fail
if [[ ! " ${foundPrinters[*]} " =~ "Printer1" || ! " ${foundPrinters[*]} " =~ "Printer2" ]]; then
echo "Failure"
else
echo "Installed"
fi