Blog Posts tagged with Mac OS X

Ask a question

KACE Agent for Macintosh - Inventory Reporting Software from Other Partitions and Running VM's

Suggestions to mitigate inventory reporting issues.

Several Macs in our environment have bloated inventory. The agent is reporting software from a running Windows VM as well as other partions with the Mac OS installed. The VM's as well as the other partitions do not have the KACE Agent installed nor do we need to manage them. Any suggestions to limit the inventory reporting to only the partiton the agent is installed on would be appreciated.

View comments (7)

Quick script to rename Macs with the name defined on your DNS server.

Background: we've got several hundred machines with IP addresses assigned via the DHCP server. All the machines have named entries in the DNS server. My goal was to write a script that would rename the computer with the DNS name defined on the DNS server. Basically, does a reverse lookup of it's IP address, and uses the resulting DNS name to label the computer. Script assumes that ethernet 0 is being used.


# This queries the DNS server to get the computer name.

ip=`ifconfig en0 | grep "inet "|awk '{print $2}'`
asset=`host $ip |awk '{print $5 $6}' |awk -F. '{print $1}'`
echo Updating various computer names.
scutil --set HostName $asset
scutil --set ComputerName $asset
scutil --set LocalHostName $asset

Be the first to comment

My postinstall scripts for after K2000 deployment (works in deploystudio and other options as well) - binds to AD, renames computer, applies many other OS customizations.

Please feel free to add any comments if you have any questions (or comments) - that's how we all learn! Note: this is an ever-evolving script that I'm constantly refining. Some of it's "original work" other parts are cobbled together from older scripts, etc. Tested and working on 10.7.1, 10.7.2, and 10.7.3.






#setup information

# enter your FQDN below



# enter a username with domain admin privs



# domain admin password



# container


#end of setup information



#rename computer with current DNS name

ip=`ifconfig en0 | grep "inet "|awk '{print $2}'`

asset=`host $ip |awk '{print $5 $6}' |awk -F. '{print $1}'`

echo Updating various computer names.

scutil --set HostName $asset

scutil --set ComputerName $asset

scutil --set LocalHostName $asset


# make sure AD is active

defaults write /Library/Preferences/DirectoryService/DirectoryService "Active Directory" "Active"

plutil -convert xml1 /Library/Preferences/DirectoryService/DirectoryService.plist


# bind machine to AD

dsconfigad -force -add $domain -computer $asset  -username "$diradmin" -password "$password" -ou "$ou"


# add AD to search path

searchpath="/Active Directory/$domain"

dscl /Search -append / CSPSearchPath "$searchpath"

dscl /Search -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath

dscl /Search/Contacts -append / CSPSearchPath "$searchpath"

dscl /Search/Contacts -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath


#disable automatic login

defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser

srm /etc/kcpassword


#bind to ntp server, sync time, set timezone

systemsetup -settimezone America/Los_Angeles -setusingnetworktime on -setnetworktimeserver time.nist.gov


#adjust sleep cycle

pmset -a displaysleep 30 disksleep 10 sleep 0


#disable graphical login; otherwise you can't log into AD accounts

defaults write /Library/Preferences/com.apple.loginwindow HideLocalUsers -bool false


#this allows you to point client machines at your desired local OSX update server. We use reposado (ubuntu based OSX software update server)

defaults write com.apple.SoftwareUpdate CatalogURL 'http://yourcatalogs'


#disable automatic login

defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser

srm /etc/kcpassword


# Enable the 2D Dock

defaults write com.apple.dock no-glass -bool true


# Disable window animations and Get Info animations in Finder

defaults write com.apple.finder DisableAllAnimations -bool true


# Automatically open a new Finder window when a volume is mounted - handy for students with external drives

defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true

defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true

defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true


# stop reopening windows after a reboot

defaults write com.apple.loginwindow TALLogoutSavesState -bool false

defaults write com.apple.loginwindow LoginwindowLaunchesRelaunchApps -bool false


# Empty Trash securely by default

defaults write com.apple.finder EmptyTrashSecurely -bool true


# Avoid creating .DS_Store files on network volumes - Windows servers, mac clients - keep those .ds_store files off the servers!!!

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true


# Disable menu bar transparency

defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false


#set power on/power off cycle

pmset repeat shutdown MTWRFSU 1:00:00 wakeorpoweron MTWRFSU 08:00:00


#reboot machine


View comments (4)

VMware Fusion and Mac VMs

Fusion 4.0.2 happily runs Mac OS X 10.5, 10.6, and 10.7 guests.  Great for testing behavior in different OS versions.

View comments (2)

How to resolve a corrupt installed Mac Application through the K1000


An application was patched or update while launched causing it to be damaged and resulting in the spinning beachball during launch or use.


There are a couple of ways that can fix this type of problem. Deciding which method to use would depend upon how wide spread the issue is and the complexity of your environment. Below are two concepts that can be used in resolving this type of problem. The first method covers the use of a shell script to stop the application process, removing it from the agent, followed by deploying and installing a known good version of the application.  With the help of a custom inventory rule and a smart machine label, the first resolution will detect other Mac agents exhibiting the same issue and run the shell script only one time to eliminate the conflict. 

The second resolution takes the process a step further by using a Plist to also provide preventative maintenance in case the issue returns after it has been resolved. The custom Plist will simply create a placeholder with no stamp inside. The file itself will still carry a standard system stamp. This is similar to what you would do with a custom registry key in a Windows environment.

The example below covers the use of an example shell script, custom inventory rule and smart machine label to resolve this type of problem (using Firefox as an example):

  1. Navigate to Scripting>choose action>add new item. Choose Online Shell Script as the script type.
  2. Upload the application used in the managed install as a dependancy.
  3. Write a script that will kill the application service, uninstall the application and then reinstall the application, followed by tagging a note when the job is complete.  Below is a sample shell script for Firefox:

  4. Save the script. Stay in Scripting. Put your cursor over the newly created script and view the identification number created for it at the bottom left of your web browser.

  5. Launch the script and edit the shell script by putting the ID number in place of the 'XXX' listed in the above example. Save.
  6. Navigate to Inventory>Software>Add New Item. Give it a title and create the Custom Inventory Rule to search for the note added to the bottom of the shell script.

  7. Save.
  8. Select Home>Label>Smart Labels>Choose Action>Add New item. Select Add New Machine Smart Label.
  9. Create the Smart Machine Label with the below similar criteria:

    NOTE: In place of 'Firefox 12 Replacement Script' use the title of the Software Item name given to the Custom Inventory Rule.

  10. The above Smart Machine Label is basic and further criteria can be added. Once catered to your liking, save it.
  11. Allow your agents to check in prior to running the script so that the machine label is given ample time to associate to the systems maching the above criteria. Then deploy the script manually or on a schedule.

Below are the steps to create a custom Plist that will be used as a container when resolving this type of issue.

  1. Navigate to Scripting>Choose Action>Add New Item.
  2. Select Script Type as Online Shell Script.
  3. Give the plist script a name. For this example, the name will be "com.kace.kinv.plist".
  4. Create and deploy the Shell Script with the contents listed in the below picture.

    This script will Date/time stamp the .plist.

  5. Save.

The next process is to create a script to uninstall/install the application with the help of the Plist. Stay in Scripting and create a new script. This time, choose Script Type as Online Kscript. Upload the application as the dependancy and use a script similar to the below screenshot using TextWrangler as an example.

To go into the script itself further, below is the breakdown of the script and categories to choose when creating this type of script.

NOTE: The File: field is not required, so leave this blank.

When completed, save the script. Once the Plist and Script have been saved, Create a Machine Smart Label to find machines that do not contain the application. The last step is to create a Custom Inventory Rule to Identify Systems with a plistReturnValue string.

NOTE: The 3142 reference is in reference to the build number of the application used in this example. This is helpful when dealing with an application publisher version that has several build numbers and you are replacing an older build number with a newer of the same version.

View comments (1)
Showing 1 - 5 of 33 results

Top Contributors

Talk About Kace K1000 Management Appliance