Assest Tag:
Cat: None#!/bin/bash
assetTag=$(osascript -e 'text returned of (display dialog "Please type in your asset tag" default answer "JS#####" buttons {"OK"} default button 1)')
sudo jamf recon -assetTag $assetTag
Policy > files and Process : Clean OS install:
"/Applications/Install macOS Mojave.app/Contents/Resources/startosinstall" --eraseinstall --newvolumename "Macintosh HD" --agreetolicense
upload sys log:
cat: system tools#!/bin/bash
serial=$(system_profiler SPHardwareDataType | awk '/Serial Number/{print $4}')
jamfID=$(curl -sku username:password -H "Accept: application/xml" https://brilyant.jamfcloud.com/JSSResource/computers/serialnumber/$serial | xpath "/computer/general/id/text()")
curl -sku api:apple123 https://brilyant.jamfcloud.com/JSSResource/fileuploads/computers/id/$jamfID -F name=@/private/var/log/system.log -X POST
wallpaper
cat: Dock#!/bin/bash
# $3 is the logged in user - default for most policies.
sudo -u $3 /usr/bin/osascript <<ENDofOSAscript
tell Application "Finder"
set the desktop picture to {"Library:Desktop Pictures:<apppp>.jpg"} as alias
end tell
ENDofOSAscript
exit 0
Versions:
#!/bin/sh
FILE_PATH="$1"
FILE_NAME="${FILE_PATH##*/}"
PKG_PATH="${FILE_PATH%/*}"
TMP_PATH=`/usr/bin/mktemp -d /tmp/PKGINFO.XXXX`
DEBUG=false
if [ ! -f "$FILE_PATH" ] || [ "$FILE_NAME##*." == "pkg" ]; then
echo "ERROR: Unable to find valid package file."
echo "USAGE: ${0##*/} /path/to/package"
exit $LINENO
fi
if $DEBUG; then
echo "FILE: $FILE_NAME"
echo "FOLDER: $PKG_PATH"
echo "TEMP: $TMP_PATH"
fi
PKG_TITLE=`/usr/sbin/installer -verbose -pkginfo -pkg "$FILE_PATH" | /usr/bin/grep -m 1 Title | /usr/bin/awk -F " : " '{print $2}'`
if ! PKG_INFO=(`/usr/bin/xar -t -f "$FILE_PATH" | /usr/bin/grep PackageInfo`); then
echo "ERROR: Unable to find package file information."
exit $LINENO
fi
pushd "$TMP_PATH" > /dev/null
for PKG_FILE in ${PKG_INFO}; do
if ! /usr/bin/xar -x -f "$FILE_PATH" "$PKG_FILE"; then
echo "ERROR: Unable to extract package file information."
exit $LINENO
else
TMP_INFO+=("$TMP_PATH/$PKG_FILE")
if $DEBUG; then echo "INFO: ${TMP_INFO[@]}"; fi
fi
done
for FILE_INFO in $TMP_INFO; do
PKG_VERSION+=(`/usr/bin/xpath "$FILE_INFO" "string(/pkg-info[1]/@version)" 2> /dev/null`)
echo "TITLE: $PKG_TITLE"
echo "VERSION: ${PKG_VERSION[@]}"
done
popd > /dev/null
/bin/rm -rf "$TMP_PATH"
Lastboot:
#!/bin/bash
bootTime=$(sysctl kern.boottime | awk '{print $5}' | tr -d ,)
#echo "$bootTime"
bootTimeFormatted=$(date -jf %s $bootTime +%F\ %T)
echo "<result>$bootTimeFormatted</result>"
Application launch
#!/bin/bash
open -a (Name of application).app
uptime:
#!/bin/bash
##defers policy
returnCode=$("/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" -windowType hud -description "Click Restart to Resrat your Mac or Choose a better time." -button1 "Restart" -button2 "Cancel" -showDelayOptions "0, 300, 3600")
selectedTime=${returnCode%?}
echo $selectedTime
buttonClicked=${returnCode: -1}
if [[ $returnCode == 3001 ]]; then
sleep 300s;
elif [[ $returnCode == 36001 ]]; then
sleep 3600s;
fi
#### push restart policy
reboot
Changing the name to SL No:
#!/usr/bin/env bash
# Get the Serial Number of the Machine
sn=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
# Set the ComputerName, HostName and LocalHostName
scutil --set ComputerName $sn
scutil --set HostName $sn
scutil --set LocalHostName $sn
Message:
osascript -e 'tell app "Finder" to display dialog "you have sucessfully rebooted"'
Last boot
#!/bin/bash
assetTag=$(osascript -e 'text returned of (display dialog "Please type in your asset tag" default answer "JS#####" buttons {"OK"} default button 1)')
sudo jamf recon -assetTag $assetTag
Battery Serial Number
#!/bin/sh
echo "<result>$(ioreg -r -c "AppleSmartBattery" | grep "BatterySerialNumber" | awk '{print $3}' | sed s/\"//g)</result>"
uptime days
#!/bin/bash
# Commands required by this script
declare -x awk="/usr/bin/awk"
declare -x sysctl="/usr/sbin/sysctl"
declare -x perl="/usr/bin/perl"
declare -xi DAY=86400
declare -xi EPOCH="$($perl -e "print time")"
declare -xi UPTIME="$($sysctl kern.boottime |
$awk -F'[= ,]' '/sec/{print $6;exit}')"
declare -xi DIFF="$(($EPOCH - $UPTIME))"
if [ $DIFF -le $DAY ] ; then
echo "<result>1</result>"
else
echo "<result>$(($DIFF / $DAY))</result>"
fi
Active power management
#!/bin/sh
echo "<result>`/usr/bin/pmset -g 2>&1 | grep \* | awk '{$NF=""; print $0}'`</result>"
Email ID
#!/bin/bash
pathData="/usr/local/dashboard/data/EmailAddresses.dat"
function DashboardStructure {
# Ensure the appropriate directories are in place.
mkdir -p /usr/local/dashboard/{bin,data,logs}
CheckAppleMail
CheckOutlook
}
function CheckAppleMail {
if [ `ps aux | grep -c "Mail.ap[p]"` -gt "0" ]; then
accountsMail=$(/usr/bin/osascript <<-EOF
tell application "Mail"
user name of every account
end tell
EOF)
for account in $accountsMail; do
if [ `echo $account | grep -c "@"` -gt "0" ]; then
echo $account | tr -d "," >> "$pathData"
fi
done
fi
}
function CheckOutlook {
if [ `ps aux | grep -c "Microsoft Outlook.ap[p]"` -gt "0" ]; then
accountsOutlook=`/usr/bin/osascript <<-EOT
tell application "Microsoft Outlook"
user name of every exchange account
end tell
EOT`
for account in $accountsOutlook; do
if [ `echo $account | grep -c "@"` -gt "0" ]; then
echo $account | tr -d "," >> "$pathData"
fi
done
accountsOutlookIMAP=$(/usr/bin/osascript <<-EOF
tell application "Microsoft Outlook"
user name of every imap account
end tell
EOF)
for account in $accountsOutlookIMAP; do
if [ `echo $account | grep -c "@"` -gt "0" ]; then
echo $account | tr -d "," >> "$pathData"
fi
done
fi
}
function ReportResult {
if [ -e "$pathData" ]; then
cat "$pathData" | sort -u > "$pathData.tmp"
mv "$pathData.tmp" "$pathData"
echo "<result>`cat $pathData`</result>"
else
echo "<result>N/A</result>"
fi
}
No comments:
Post a Comment