loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
For more details see:
https://scriptingosx.com/2019/09/get-current-user-in-shell-scripts-on-macos/
loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
For more details see:
https://scriptingosx.com/2019/09/get-current-user-in-shell-scripts-on-macos/
Active Directory login, Keyserver access, SafeConnect, etc all require the connecting client to have a time setting that is within 5 minutes or so of the server’s time setting. It is therefore useful to use a “network time protocol” server to set your local computer’s time to the “correct” time.
Macs typically use “time.apple.com” to set their time from the network. This is fine most of the time. 😉
In the rare times you want to set a different time server on a Mac, use Terminal and enter the command:
sudosystemsetup -setnetworktimeserver <timeserver>(replace<timeserver> with the address of the time server you want to use as in 137.165.4.21 for Williams College)
Since this is a command run with “sudo”, you’ll be asked to enter the account password and that account needs to be authorized as a “Super User” or “root” user.
By the way – the GUI interface in the “Date & Time” System preference only allows you to choose time servers hosted by Apple.
For more details see the web page at:
http://hints.macworld.com/comment.php?mode=view&cid=98039
Some software can not be installed on the master image computer because it needs to be uniquely installed on each clone. So rather then have to copy packages to each clone after imaging, why not put the packages in a known location and then call the installer remotely using the command like:
installer -pkg /Users/labadmin/Desktop/post/Sophos_10.mpkg -target /
See the complete man page at:
I use lpadmin -x to remove printers when needed as in:
lpadmin -x Spencer-116-Color
lpadmin can be used for a bunch of other chores. See:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man8/lpadmin.8.html
Interestingly, the -x option isn’t listed in the man page!
See also: http://hints.macworld.com/article.php?story=20061203221317612 For additional options like clearing queues …
Sometimes it’s useful to use the computer description field to store information like the the image version. I typically do this in automated post imaging tasks, however, it is sometime necessary to manually reset this description field.
The command line to do that is:
net config server /srvcomment:computer_description
See: http://lifeofageekadmin.com/changing-windows-computer-description-from-a-command-prompt/
To control the network settings with the command line try:
networksetup -listnetworkserviceorder
Then:
To display current state of wireless:
networksetup -getairportpower <device name>
Or to turn wireless off or on:
networksetup -setairportpower <device name> <on off>
For a longer description of these see: