Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Created March 7, 2012 22:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talkingmoose/1996861 to your computer and use it in GitHub Desktop.
Save talkingmoose/1996861 to your computer and use it in GitHub Desktop.
Shell script to configure Microsoft Communicator user name and email address
#!/bin/sh
########################### About this script ##########################
# #
# Purpose: Populates user name and email address settings #
# for Communicator 2011 for Mac. This script resides #
# in /Library/talkingmoose/Scripts and is launched #
# by launch agent net.talkingmoose.CommunicatorSetup.plist. #
# #
# Created by William Smith #
# Last update February 23, 2012 #
# #
# Version history #
# 1.0 Created CommunicatorSetup-1.0.sh script #
# #
##################################################################################
# Running checkSetupDone function to determine if the rest of this script needs to run.
# Yes, if $HOME/Library/Preferences/com.microsoft.Communicator.plist file does not exist.
# Otherwise, assume this setup script has already run for this user and does not
# need to run again.
checkSetupDone() {
if [ -f $HOME/Library/Preferences/com.microsoft.Communicator.plist ] ; then
exit 0
fi
}
populateUserInformation() {
# Logfile
LOGFILE="$HOME/Library/Logs/CommunicatorSetup.log"
# Script version
SCRIPTVERSION=$0
date "+%A %m/%d/%Y %H:%M:%S Running Script: $SCRIPTVERSION" >> $LOGFILE
# Get current username
USERNAME=$( id -un )
if [ $? = 0 ] ; then
date "+%A %m/%d/%Y %H:%M:%S User name is $USERNAME." >> $LOGFILE
else
date "+%A %m/%d/%Y %H:%M:%S ERROR! Unable to read user name." >> $LOGFILE
fi
# Look up user email address
# Uncomment next line for Active Directory lookup
EMAILADDRESS=$( dscl "/Active Directory/All Domains/" -read /Users/$USERNAME EMailAddress | awk 'BEGIN {FS=" "} {print $2}' )
# Uncomment next line for local directory lookup
# EMAILADDRESS=$( dscl . -read /Users/$USERNAME EMailAddress | awk 'BEGIN {FS=" "} {print $2}' )
if [ $? = 0 ] ; then
date "+%A %m/%d/%Y %H:%M:%S User email address is $EMAILADDRESS." >> $LOGFILE
else
date "+%A %m/%d/%Y %H:%M:%S ERROR! Unable to read user email address." >> $LOGFILE
fi
# Write user information to Communicator preferences file
defaults write $HOME/Library/Preferences/com.microsoft.Communicator UserLogonName $USERNAME
if [ $? = 0 ] ; then
date "+%A %m/%d/%Y %H:%M:%S User logon name set to $USERNAME." >> $LOGFILE
else
date "+%A %m/%d/%Y %H:%M:%S ERROR! Unable to set user logon name to $USERNAME." >> $LOGFILE
fi
defaults write $HOME/Library/Preferences/com.microsoft.Communicator UserSIPID $EMAILADDRESS
if [ $? = 0 ] ; then
date "+%A %m/%d/%Y %H:%M:%S User logon email address set to $EMAILADDRESS." >> $LOGFILE
else
date "+%A %m/%d/%Y %H:%M:%S ERROR! Unable to set user logon email address to $EMAILADDRESS." >> $LOGFILE
fi
# Accept license agreement - Prevents initial license agreement from appearing for each user
defaults write $HOME/Library/Preferences/com.microsoft.Communicator acceptedSLT130 -bool true
if [ $? = 0 ] ; then
date "+%A %m/%d/%Y %H:%M:%S License agreement accepted." >> $LOGFILE
else
date "+%A %m/%d/%Y %H:%M:%S ERROR! Unable to accept license agreement." >> $LOGFILE
fi
# Script spacer - adds a couple of blank lines to the end of the log session
awk 'BEGIN { print "\n" }' >> $LOGFILE
}
checkSetupDone
populateUserInformation
exit 0
@talkingmoose
Copy link
Author

Save the above file as CommunicatorSetup-1.0.sh into /Library/talkingmoose/Scripts.

@cemsky
Copy link

cemsky commented Apr 24, 2012

Thanks for the script!
It will be great to add the disable 2 pop up windows for asking "Would you like Lync to be the default app"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment