#!/bin/bash ########################################################################## # Shellscript : Sammelt bestimmte Informationen zum Gerät. # Autor : Andreas Vogel, macenterprise gmbh, 2020 # Discription : Nach dem sammeln der Inforamtionen kann der User über Mailto # eine Email an den ServiceDesk verschicken. ########################################################################## currentUser=$( stat -f "%Su" /dev/console ) supportEmail="servicedesk@ing.de" ############################# show General Informations ################################################ FindComputerName=$( /usr/sbin/scutil --get ComputerName ) computerName="Computer Name: $FindComputerName" FindSerialNumber=$( /usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep "Serial Number" | /usr/bin/awk -F ": " '{ print $2 }' ) serialNumber="Serial Number: $FindSerialNumber" macOSVersion=$( /usr/bin/sw_vers -productVersion) operatingSystem="Operating System: $macOSVersion" ############################# Active Directory / Informations and Check ############################### adDomain="diba.corp.int" netbiosDomain="DOMDIBACORP" CheckAD=$( /usr/sbin/dsconfigad -show | /usr/bin/grep "Directory Domain" | /usr/bin/awk -F "= " '{ print $2 }' ) ADInfo="Connectet to AD: $CheckAD" if [ "$CheckAD" = "$adDomain" ]; then AD="Bound to AD: Yes" else AD="Bound to AD: No" fi TestADBinding=$( /usr/bin/dscl "/Active Directory/$netbiosDomain/All Domains" read /Users ) if [ "$TestADBinding" = "name: dsRecTypeStandard:Users" ]; then testAD="Test AD Connection: Success" else testAD="Test AD Connection: Fail" fi ############################# show Network Informations ############################### networkServices=$( /usr/sbin/networksetup -listallnetworkservices | /usr/bin/grep -v asterisk ) while IFS= read aService do activePort=$( /usr/sbin/networksetup -getinfo "$aService" | /usr/bin/grep "IP address" | awk '{print $3}' ) if [ "$activePort" != "" ] && [ "$activeServices" != "" ]; then activeServices="$activeServices\n$aService $activePort" elif [ "$activePort" != "" ] && [ "$activeServices" = "" ]; then activeServices="$aService $activePort" fi done <<< "$networkServices" activeServices=$( echo "$activeServices" | /usr/bin/sed '/^$/d') FindSSID=$( /usr/sbin/networksetup -getairportnetwork en0 | /usr/bin/awk -F ": " '{ print $2 }' ) SSID="SSID: $FindSSID" ############################# show Summary Informations ############################### displayInfo=" *************** - GENERAL - ******************* Computer Name: $FindComputerName Serial Number: $FindSerialNumber Operating System: $macOSVersion *************** - NETWORK - ******************* $activeServices SSID: $FindSSI ************ - ACTIVE DIRECTORY - ************ $ADInfo $AD $testAD **************************************************" ############################# show Summary Informations PopUp############################### ShowSummary="button returned of (display dialog \"$displayInfo\" with title \"Computer Information\" with icon file posix file \"/System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns\" buttons {\"Email an ServiceDesk\", \"OK\"} default button {\"OK\"})" clickedButton=$( /usr/bin/osascript -e "$ShowSummary" ) if [ "$clickedButton" = "Email an ServiceDesk" ] then sudo -u "$currentUser" /usr/bin/open "mailto:$supportEmail?subject=Bitte ein Ticket zum Gerät $FindComputerName erstellen &body= Anbei die Geräteinformation: $displayInfo" fi