Forum Replies Created
-
AuthorPosts
-
blackholemac
ParticipantA final note to close this thread with. With the use of MCX and a little bit of scripting I found the way that makes this work well within our environment. Being that this is a forum and I’ve already asked questions, now it is my turn to give answers. I am happy to share my advice, scriptcode and details for those that face this same issue.
[b]PART 1: MCX[/b] During testing I created a new computer group and added my test machine as a member. (We manage policy typically by computer group with a very few exceptions.) In the details tab, I imported the following preferences: com.microsoft.office.plist, com.microsoft.error_reporting.plist, and com.microsoft.autoupdate2.plist. I set the MCX to only manage the following:
com.microsoft.autoupdate2:[code]
[/code]com.microsoft.error_reporting:[code]
HowToCheck
Manual
LastUpdate
2001-01-01T00:00:00Z
[/code]com.microsoft.office:[code]
SQMReportsEnabled
ShipAssertEnabled
[/code]You will notice on the last one that I left out the 14\UserInfo\UserName key. I did that on purpose. If I statically define a user name there, it will brand that on each and every machine. While that seems desirable, it is NOT because then if you wish to use or set up Outlook, you have to remember to change the “Me” contact to the user’s name during setup or every message they send out will come from the statically defined value in the 14\UserInfo\UserName key. Hence the need for second part to this:
14\FirstRun\SetupComplete
1
14\UserInfo\UserOrganization
Company Name
[b]PART 2: SCRIPTING[/b] So okay we have Office First Run suppressed save for the 14\UserInfo\UserName key. You could just not populate this key and Office 2011 will query the user to populate this data upon first run. Perhaps a good idea in an un-managed office setting, but not so helpful in a controlled lab environment.
To work around this issue, I have created a script that needs to be run as the user (NOT ROOT) that defines the 14\UserInfo\UserName key for each user upon logging. I implemented this script using a LaunchAgent at the computer level. Some of the documentation suggest putting this at the user level and only running it once. I wish to have it run and be forced each time (kind of like an MCX control only not using that mechanism)
Here is the code for the script I used to change the 14\UserInfo\UserName key:[code]#!/bin/bash
#declare the variables. We have a magic triangle implementation binding both to AD and OD. We also utilize portable home directories.
username=`whoami`
lastname=`dscl . -read /Users/$username RealName | awk ‘ NR > 1 {print $2}’`
firstname=`dscl . -read /Users/$username RealName | awk ‘ NR > 1 {print $1}’ | tr -d ‘,’`#use PlistBuddy to add the username string and set the value based on the earlier declared variables
/usr/libexec/PlistBuddy -c “Add :14\\\UserInfo\\\UserName string” ~/Library/Preferences/com.microsoft.office.plist
/usr/libexec/PlistBuddy -c “set :14\\\UserInfo\\\UserName ‘$firstname’ ‘$lastname'” ~/Library/Preferences/com.microsoft.office.plist#this script is called by a LaunchAgent so I really don’t want to know about it or inform the user in labs even if it fails
exit 0[/code]
Here is the code for the LaunchAgent installed to /Library/LaunchAgents:
[code]
[/code]
Label
us.in.k12.lsc.PersonalizeOffice
ProgramArguments
/Library/Scripts/Admin/personalizeoffice.sh
RunAtLoad
Finally, don’t forget to load the LaunchAgent:
[code]launchctl load[/code]Now I end this post by saying that this is NOT original work by any means. I created a custom solution for our environment that draws heavily on advice coming from these three websites: http://www.officeformachelp.com/office/administration/mcx/
http://www.osxdeployment.info/wiki/Office_2011_Settings
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.htmlI include the launchd man page article because it explains why I chose a computer level LaunchAgent and not a login hook or a LaunchDaemon to call this script.
Hopefully this has been helpful and I thank everyone for helping to answer my questions.
blackholemac
blackholemac
Participanttitanonearth,
I want to thank you for this posting. Oddly enough, someone beat you to it offline less than 12 hours ago, but I’m glad to see your post as it corroborates the info they passed along with an MS weigh-in. Here was what they sent me:
http://www.osxdeployment.info/wiki/Office_2011_Settings
Same concept but the original source was unsure of a couple of MCX entries and the MS weigh in uses fewer keys to manage which in this case is a cleaner approach.
Thank you,
blackholemacblackholemac
ParticipantGreg,
I want to thank you. I felt bad with my original post because it looked like I wanted someone to “do it for me”. That drove my to create my shutdown AppleScript that works really well oddly enough. I knew AppleScript was the easiest language that meets my boss’s requirement that working users be informed graphically of the shutdown. I noticed including a message with the shutdown command does NOT display it graphically so I took my best scripting skills and put together an AppleScript applet that seems to handle shutdown well.
I did try handling the wrapper script myself as well. After your first post, it got me to step away from the computer and understand the scripting logic. I even diagrammed it on paper….shebang, declare a variable that captures the hour, if it is during business hours, exit 0, else if during any other time call the AppleScript with the open command then exit 0.
As for the syntax, I started panicking though when I captured the hour and tried to do math computations with it to test it in a dummy script. I failed miserably. I figured if I couldn’t do math with what was captured, then how would I deal with greater than/less than?
Your script showed me the exact syntax for the greater than/less than. I am grateful.
Brian Martin
Lafayette School CorporationP.S. I am a big fan of your articles on managing MS Office mcx settings and your frustration with Software Update. Your Office advice made it easy for me to force default saving in the old format. Your Software Update thoughts are ones I share. I have wrote a stupid script that calls the command line version of software update but this is a rather clunky solution that Apple could easily make better.
blackholemac
ParticipantAlright…being that I am a very novice scriptwriter [I come from the old school Mac OS 7,8,9 days 🙂 ] I took the easy way out of this problem. I am using the root user’s crontab instead of launchd to run my AppleScript at various given hours.
I can use the following command and it does properly work and my boss is happy with the functionality:
0 0,2,4,6,18,20,22 * * * /usr/bin/open
Greg, I like your approach the best because it would allow me to use launchd and do this “The Right Way”. I could have a single launchd job run every 7200 seconds and call a wrapper bash script that determines the system time (only in hours and in an integer format) and if it is during business hours, then it would ‘exit 0’ and do nothing, else it would launch the AppleScript and then it would take over from there. I can write a launchd job that runs every 7200 seconds…that’s easy with Lingon but without a proper wrapper script then I’m afraid it would try to force shutdown the computer during business hours.
Sadly, I am not an experienced enough scripter to write such a wrapper script. Nor do I know if it is possible to translate my cron line above to an equivalent launchd plist without writing a wrapper script.
If anyone has any advice on either, I welcome it and thank you for it in advance. If not, I can use cron and all will work fine…I just don’t like relying on technology that may be deprecated.
Brian Martin
Lafayette School Corporationblackholemac
ParticipantAlright…I have narrowed this issue significantly with the help of some good ole’ AppleScripting, launchd agents and relying on Workgroup Manager’s Energy Saver MCX setting for the initial 6 p.m. shutdown.
I am posting the AppleScript code I used at the bottom of this message by the way for free use by anyone who sees fit to use it, but I have one single remaining issue in dealing with implementation:
BEGIN APPLESCRIPT CODE
(*
This applet informs the user that a mandatory, forced shutdown will be taking place in five minutes time. The user can either shut down the system immediately or ask for an additional five minutes of time to allow for saving of files. The software was developed by Brian Martin for the Lafayette School Corporation and is free and open for anyone to use as they see fit though the author and Lafayette School Corporation assume ZERO liability for any damage that may be incurred. I advise anyone to compile this as a run-only script so that passwords aren’t easily exposed.
*)set question to display dialog “Include a message to the user explaining the company policy regarding shutdowns and that they should click on one of the buttons to either shutdown immediately or to ask for five minutes of time to save files. It should also explain that no action will default to five minutes and then a forced shutdown.” with title “Automated Shutdown” buttons {“Shutdown NOW!”,”Let Me Have 5 Minutes to Save My Documents”} default button 2 giving up after 300
set answer to button returned of question
if answer is equal to “Let Me Have 5 Minutes to Save My Documents” then
delay 300
do shell script “shutdown -h now” user name “yours here” password “yours here” with administrator privileges
else
do shell script “shutdown -h now” user name “yours here” password “yours here” with administrator privilegesend if
END APPLESCRIPT CODE
The issue: I am having issues formatting a single launchd job that would call this script 7200 seconds during the shutdown hours, but that would not activate the script during normal business hours..
Right now, I am using a very messy method that involves setting up 6 individual launchd jobs that cover each increment from 8 p.m. to 6 a.m. that I want the computer to shutdown.
I hope there is a cleaner way to do this with launchd, but I am lacking the knowledge how to make it so even after re-reading Apple’s Advanced System Administration Certification guide (very detailed and informative resource on launchd) and using Peter Borg’s Lingon.
Hopefully someone here is very skilled at working with launchd and will have some ideas. Please let me know if you need any followup information in assisting me and I thank anyone in advance for their time.
Brian Martin
Lafayette School Corporation -
AuthorPosts
Recent Comments