Saturday, 19 April 2014

Lync for mac 14.0.8 package

So microsoft brought out an update to Lync for mac, this update fixes the contacts not searchable issue on mavericks. There are a few changes when its installed though.

Previously in order to auto populate a Lync users ID from the AD server all we had to do was populate the com.microsoft.Lync.plist with the sign in name and Lync address.

But in Lync 14.0.8 the /Users/UserName/Library/Preferences/com.microsoft.Lync.plist file is created only when lync is launched for the first time and the license agreement accepted. So for a new install the old method doesn't work. We worked around it by displaying the sign-in details as part of a postflight script that ran after Lync got installed.

To create the lync for mac package use composer to capture a snapshot before Lync is installed.

Modify the  MicrosoftLyncRegistrationDB.plist located at /Library/Preferences with the Lync internal and external server name.


Create the package after Lync is installed and remove unnecessary items.
You'll need to  make sure that the modified MicrosoftLyncRegistrationDB.plist is in the package,












--> Then put in preflight and postflight scripts as follows:Then after putting in the scripts Build your pkg.
I'll put in my scripts here, on condition that you credit me with any future use:
Preupgrade.sh:
################################################################
#!/bin/sh
## preinstall
#Lync for mac preupgrade script created by tausif
#created to kill lync and remove the sip_* directory in current AD users home folder .
USERNAME=$(ls -l /dev/console | awk '{print $3}' )
#get console user
HOME=$(sudo dscl . -read /Users/$USERNAME NFSHomeDirectory | awk '{print $2}')
#get current users home directory
MobileUsers=`dscl . read /Users/$USERNAME OriginalNodeName | grep "Active Directory"`
#this is to filter out local users and target only AD users
logFile="/private/var/log/LyncPreinstall.log"
log () {
echo $1
echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}

LYNC_PID=$(ps ax | grep "/Applications/Microsoft Lync.app/Contents/MacOS/Microsoft Lync" | grep -v grep | awk '{ print $1 }')
kill -9 ${LYNC_PID}
if [ $? = 0 ] ; then
log "Lync is open killing it now "
else
log "Lync is not running"
fi
for username in $MobileUsers
do
rm -rf $HOME/Documents/Microsoft\ User\ Data/Microsoft\ Lync\ Data/sip_*
log "Removed SIP dir"
done

exit 0          ## Success
exit 1          ## Failure

################################################################

Postfilght.sh:
################################################################
#!/bin/sh
## postinstall.sh
#Lync for mac postupgrade script created by tausif
#created to install lync, diplay Lync credentials to user,add lync to user's dock and remove the sip_* #directory in current AD users home folder .
USERNAME=$(ls -l /dev/console | awk '{print $3}' )
#get current user
HOME=$(sudo dscl . -read /Users/$USERNAME NFSHomeDirectory | awk '{print $2}')
#get current users home directory
EMAILADDRESS=$( dscl /Search -read /Users/$USERNAME | grep -i msRTCSIP-PrimaryUserAddress | awk '{print $2}'| cut -c 5- )
#very tricky get Lync signin address
CORP='CORP\\'
LYNCNAME=$CORP$USERNAME
#do this because osascript is strange when run from shell
MobileUsers=`dscl . read /Users/$USERNAME OriginalNodeName | grep "Active Directory"`
#filter only for AD users, we don't want to do this from a local account
logFile="/private/var/log/LyncPostinstall.log"
log () {
echo $1
echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}
#log everything
#check for local user running this.
if [[ $MobileUsers != " /Active Directory/CORP/corp.fairisaac.com" ]];
then
/usr/bin/osascript << EOF
tell application "System Events"
    activate
    display dialog "Lync auto-setup applies only to Active Directory accounts. Aborting " with title "Aborting" with icon note buttons {"OK"} default button 1
end tell
EOF
log "Local account used"
exit 1
fi
#tell user his lync details
/usr/bin/osascript << EOF
 tell application "System Events"
        activate
        display dialog "Please note your sign in details and click ok to complete the Installation" & "\nLync sign-in Address: \"$EMAILADDRESS\""  &  " \nLync Username: \"$LYNCNAME\" " with title "Lync Sign in Details" with icon note buttons {"OK"} default button 1
    end tell
EOF
log "sign in details displayed"
#add lync icon to dock
for username in $MobileUsers
do
defaults write $HOME/Library/Preferences/com.apple.dock.plist persistent-apps -array-add "tile-datafile-data_CFURLString/Applications/Microsoft Lync.app/_CFURLStringType0"
done
log "Lync icon added to dock"
sleep 5

chown $USERNAME:"CORP\Domain Users" $HOME/Library/Preferences/com.apple.dock.plist
chmod 600 $HOME/Library/Preferences/com.apple.dock.plist
log "perms changed on dock plist"
#bounce dock
killall -HUP cfprefsd
#cfprefsd for mavericks
killall -HUP Dock

log "bounced dock"

exit 0        ## Success
exit 1        ## Failure

Saturday, 22 June 2013

Office 2010 Icons blank.

So, we were facing issues with some of our domain users losing permissions on their C: drives, and when we re-added their permissions were faced with the annoying side effect of all their office icons going blank and reflecting windows default icons.Rebuilding the icon cache did not help them in this instance.

So i found that the C:\Windows\installer folder was getting flushed every time the permissions were reset:

to fix this:

1: The installer folder is hidden by default to unhide it: Open C:\Windows, click on organize -- folder options -- view -- and uncheck  "Hide Protected operating system files"
click Show hidden files and hit OK.

2: Download the archive from here:
https://www.dropbox.com/s/ltm1f7znmdpvsxr/%7B90140000-0011-0000-0000-0000000FF1CE%7D.zip
and drag and drop its contents into the folder C:\Windows\installer (Very inportant-->" the whole folder in the archive should be dragged and dropped, not the files within the folder ")

3: Log out and log back in and your office 2010 icons should come back.

Detect autopilot session

  Ensuring that some apps only install during autopilot is not easily accomplished, you can use the below powershell script as a requiremen...