Skip to main content
Question

Microsoft Silverlight update script


Forum|alt.badge.img+11

Thanks to @mm2270 and @rtrouton I have taken Mike's update script and Rich's adobe flash update script and figured out how to make the Microsoft Silverlight script.

1#!/bin/sh
2
3# Silverlight Lastest Version URL
4###############################
5silLightCheckURL="http://www.microsoft.com/getsilverlight/locale/en-us/html/Microsoft%20Silverlight%20Release%20History.htm"
6URL="${silLightCheckURL}"
7
8###############################
9
10# Determine OS version
11###############################
12osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
13
14
15# Current Microsoft Silverlight Version
16###############################
17curr_Vers=$( curl -sf "${URL}" 2>/dev/null | grep -m1 "Silverlight 5 Build" | awk -F'[>|<]' '{print $2}' | tr ' ' '
18' | awk '/Build/{getline; print}' )
19
20# Download URL Microsoft Silverlight Version
21###############################
22download_url=$( curl -sfA "$UGENT" "http://go.microsoft.com/fwlink/?LinkID=229322" | awk -F'"' '{print $2}' | sed '/^$/d' )
23sl_dmg="silverlight.dmg"
24
25
26if [[ ${osvers} -lt 6 ]]; then
27 echo "Buy a new Mac!"
28fi
29
30if [[ ${osvers} -ge 6 ]]; then
31
32 # Download the latest Microsoft Silverlight software disk image
33
34 /usr/bin/curl --output "$sl_dmg" "$download_url"
35
36 # Specify a /tmp/silverlight.XXXX mountpoint for the disk image
37
38 TMPMOUNT=`/usr/bin/mktemp -d /tmp/silverlight.XXXX`
39
40 # Mount the latest Silverlight disk image to /tmp/silverlight.XXXX mountpoint
41
42 hdiutil attach "$sl_dmg" -mountpoint "$TMPMOUNT" -nobrowse -noverify -noautoopen
43
44 pkg_path="$(/usr/bin/find $TMPMOUNT -maxdepth 1 ( -iname *Silverlight*.pkg -o -iname *Silverlight*.mpkg ))"
45
46 # Before installation on Mac OS X 10.7.x and later, the installer's
47 # developer certificate is checked to see if it has been signed by
48 # Microsoft's developer certificate. Once the certificate check has been
49 # passed, the package is then installed.
50
51 if [[ ${pkg_path} != "" ]]; then
52 if [[ ${osvers} -ge 7 ]]; then
53 signature_check=`/usr/sbin/pkgutil --check-signature "$pkg_path" | awk /'Developer ID Installer/{ print $5 }'`
54 if [[ ${signature_check} = "Microsoft" ]]; then
55 # Install Microsoft Silverlight from the installer package stored inside the disk image
56 /usr/sbin/installer -dumplog -verbose -pkg "${pkg_path}" -target "/"
57 fi
58 fi
59
60 # On Mac OS X 10.6.x, the developer certificate check is not an
61 # available option, so the package is just installed.
62
63 if [[ ${osvers} -eq 6 ]]; then
64 # Install Microsoft Silverlight from the installer package stored inside the disk image
65 /usr/sbin/installer -dumplog -verbose -pkg "${pkg_path}" -target "/"
66 fi
67 fi
68
69 # Clean-up
70
71 # Unmount the Microsoft Silverlight disk image from /tmp/silverlight.XXXX
72
73 /usr/bin/hdiutil detach "$TMPMOUNT"
74
75 # Remove the /tmp/silverlight.XXXX mountpoint
76
77 /bin/rm -rf "$TMPMOUNT"
78
79 # Remove the downloaded disk image
80
81 /bin/rm -rf "$SilverlightDMG"
82fi
83
84
85exit 0

25 replies

dstranathan
Forum|alt.badge.img+19
  • Valued Contributor
  • 569 replies
  • December 8, 2015

Thanks @kenergy. Worked great for me (just ran it manually for a test).

Just curious: What apps/sites are dependent on MS Silverlight in your environment?


Forum|alt.badge.img+14
  • Contributor
  • 388 replies
  • December 8, 2015

@dstranathan For us, Outlook Web App 2010. We're moving to Exchange 2013 eventually.


Forum|alt.badge.img+11
  • Author
  • Contributor
  • 33 replies
  • December 8, 2015

None, I just add it as part of the default setup so users don't have to wait for it to be packaged and then put in Self Service.


Forum|alt.badge.img+12
  • Valued Contributor
  • 226 replies
  • December 9, 2015

We use grammar testing software here that needs it: http://www.egumpp.com


Forum|alt.badge.img+5
  • Contributor
  • 28 replies
  • January 26, 2016

Thanks for the script, and i lol'ed at this.

if [[ ${osvers} -lt 6 ]]; then echo "Buy a new Mac!"
fi

I also added an If statement to check to see if the current version is installed already and if it is to do nothing. This way i can set my script to run once a week on all my computers.


Forum|alt.badge.img+5
  • Contributor
  • 40 replies
  • February 2, 2016

Thanks for the script!

Is there a reason I shouldn't just do something like:

1download_url="http://go.microsoft.com/fwlink/?LinkID=229322"
2sl_dmg="silverlight.dmg"
3/usr/bin/curl -sfL --output "$sl_dmg" "$download_url"

which would just let curl follow the redirect and download, rather than

1download_url=$( curl -sfA "$UGENT" "http://go.microsoft.com/fwlink/?LinkID=229322" | awk -F'"' '{print $2}' | sed '/^$/d' )
2sl_dmg="silverlight.dmg"
3/usr/bin/curl --output "$sl_dmg" "$download_url"

Forum|alt.badge.img+5
  • Contributor
  • 28 replies
  • February 17, 2016

Im getting a curl: (3) malformed error when i look at the log files in casper. It also does not update correctly. It seems to work half the time.


iJake
Forum|alt.badge.img+21
  • Contributor
  • 279 replies
  • February 17, 2016

I adapted the script from @kenergy with one we already had for Flash and this is what we use. You'd need to modify the Log and DMG download locations for your own environment. The script will also, if it has updated Silverlight, ensure that it is properly enabled. We've had issues with it getting turned off in Safari.

1#!/bin/bash
2
3## HEADER
4# Script Title: Microsoft Silverlight Downloader
5# Authot: Jacob Davidson <jadavids@cisco.com>
6
7## DEFINITIONS
8SoftwareTitle=Silverlight5
9SectionTitle=Silverlight5
10LogFolder='/PATH/TO/LOG'
11LogFile="$LogFolder/$SoftwareTitle.log"
12TimeStamp=$(date "+%Y %b %d %T")
13ConsoleUser=$(stat -f %Su '/dev/console')
14LogSize=$(stat -f%z $LogFile)
15MaxSize=1000000
16BackupLocation="/Path/TO/PACKAGE/DOWNLOAD"
17InstallDMG="silverlight.dmg"
18silLightCheckURL="http://www.microsoft.com/getsilverlight/locale/en-us/html/Microsoft%20Silverlight%20Release%20History.htm"
19URL="${silLightCheckURL}"
20FilerURL="http://go.microsoft.com/fwlink/?LinkID=229322"
21WebVersion=$( curl -sf "${URL}" 2>/dev/null | grep -m1 "Silverlight 5 Build" | awk -F'[>|<]' '{print $2}' | tr ' ' '
22' | awk '/Build/{getline; print}' )
23pluginDisabledCheck=$(defaults read $homeFolder/Library/Preferences/com.apple.Safari.plist DisabledPlugInInfo | grep -c SilverlightPlugin)
24pluginDisabledFix=$(/usr/libexec/PlistBuddy -c "Delete :DisabledPlugInInfo:com.microsoft.SilverlightPlugin" $homeFolder/Library/Preferences/com.apple.Safari.plist)
25
26
27## LOGGING
28writeLog(){ echo "[$TimeStamp] [$SoftwareTitle] [$SectionTitle] [$ConsoleUser]: $1" >> $LogFile; }
29[[ -d $logFolder ]] || mkdir -p -m 775 "$LogFolder"
30[[ $LogSize -ge $MaxSize ]] && rm -rf "$LogFile"
31
32## FUNCTIONS
33grabConsoleUserAndHome(){
34 currentUser=$(stat -f %Su "/dev/console")
35 homeFolder=$(dscl . read "/Users/$currentUser" NFSHomeDirectory | cut -d: -f 2 | sed 's/^ *//'| tr -d '
36')
37}
38
39
40## BODY
41SectionTitle=Verification
42WebVersionInt=$(echo "${WebVersion//.}")
43if [[ -e "/Library/Internet Plug-Ins/Silverlight.plugin" ]]; then
44 CurrentVersion=$(defaults read "/Library/Internet Plug-Ins/Silverlight.plugin/Contents/Info.plist" CFBundleVersion)
45 CurrentVersionInt=$(echo "${CurrentVersion//.}")
46 [[ "$WebVersionInt" -le "$CurrentVersionInt" ]] && writeLog "Silverlight up to date at: $CurrentVersion" && exit 0
47fi
48writeLog "Installation Date: $TimeStamp"
49writeLog "Active Console User: $ConsoleUser"
50if [[ -e "/Library/Internet Plug-Ins/Silverlight.plugin" ]]; then
51 writeLog "Installed Silverlight version: $CurrentVersion"
52else
53 writeLog "Existing installation of Silverlight not found. Exiting"
54 exit
55fi
56writeLog "Current available version: $WebVersion"
57SectionTitle=Download
58[[ -d "$BackupLocation" ]] || mkdir -p -m 775 "$BackupLocation"
59FilerConnection=$(curl -L -s -o "/dev/null" --silent --head --write-out '%{http_code}' "$FilerURL" --location-trusted -X GET)
60writeLog "Connection status: $FilerConnection"
61if [[ "$FilerConnection" -eq 200 ]]; then
62 /usr/bin/curl -sfL "$FilerURL" -o "$BackupLocation/$InstallDMG" --silent --location-trusted >> "$LogFile"
63else
64 writeLog "Connection error"
65 echo "Unable to download Silverlight from Microsoft"
66 exit 1
67fi
68SectionTitle=Mount
69MountPoint=$(/usr/bin/mktemp -d /tmp/Silverlight.XXXX)
70if [[ -e "$BackupLocation/$InstallDMG" ]]; then
71 hdiutil attach "$BackupLocation/$InstallDMG" -mountpoint "$MountPoint" -nobrowse -noverify -noautoopen
72 writeLog "Mounted DMG $BackupLocation/$InstallDMG at $MountPoint"
73else
74 writeLog "Unable to find DMG at $BackupLocation"
75 ls -la "$BackupLocation" >> "$LogFile"
76 echo "Install DMG download not successful"
77 exit 1
78fi
79SectionTitle=Install
80SilverlightInstaller=$(find "$MountPoint" -maxdepth 1 ( -iname *.pkg -o -iname *.mpkg ))
81if [[ -e "$SilverlightInstaller" ]]; then
82 writeLog "Executing package at: $SilverlightInstaller"
83 installer -dumplog -pkg "$SilverlightInstaller" -target / >> "$LogFile"
84else
85 writeLog "Installer package not found"
86 echo "Installer package not found on DMG"
87 exit 1
88fi
89SectionTitle=CleanUp
90writeLog "Unmounting install DMG"
91hdiutil detach "$MountPoint" >> "$LogFile"
92[[ -e "$BackupLocation/$InstallDMG" ]] && rm -rfv "$BackupLocation/$InstallDMG" >> "$LogFile"
93SectionTitle=Confirmation
94CurrentVersion=$(defaults read "/Library/Internet Plug-Ins/Silverlight.plugin/Contents/Info.plist" CFBundleVersion)
95CurrentVersionInt=$(echo "${CurrentVersion//.}")
96writeLog "Installed Silverlight version: $CurrentVersion"
97if [[ "$WebVersionInt" = "$CurrentVersionInt" ]]; then
98 SectionTitle=Complete
99 writeLog "Update successful"
100 writeLog "Verifying Plugin Enabled"
101 grabConsoleUserAndHome
102 if [[ $pluginDisabledCheck -gt 0 ]]
103 then
104 writeLog "Enabling plugin"
105 $pluginDisabledFix
106 else
107 writeLog "Verified"
108 fi
109else
110 writeLog "Update failed"
111 echo "Silverlight not updated"
112 exit 1
113fi
114
115## FOOTER
116exit 0

peterlbk
Forum|alt.badge.img+11
  • Jamf Heroes
  • 68 replies
  • March 18, 2016

Hi iJake,

why did you exit if there's no version found? I removed it and now it can always be installed...

Anyway, just to let you know - great script btw!


iJake
Forum|alt.badge.img+21
  • Contributor
  • 279 replies
  • March 20, 2016

@peterloobuyck We only wanted to update clients that already had it in our case. Glad you found it useful and were able to modify it.


Forum|alt.badge.img+6
  • Contributor
  • 49 replies
  • July 8, 2016

Hi All - Great script and thanks for the help. Has anyone had any luck getting this to work through a proxy? We actually use an automatic configuration script (.pac) file. Appreciate any info.
Thanks!


Forum|alt.badge.img+6
  • Contributor
  • 24 replies
  • April 7, 2017

@iJake This script worked well with slight modification. I added the signature check from the initial script.

Unfortunately the script throws failed because the geniuses at Microsoft must have not updated the version name correctly. Downloading the latest currently available reads 5.1.50905.0 but when installed reads 5.1.50901.0, even when installing manually.


Forum|alt.badge.img+10
  • New Contributor
  • 306 replies
  • April 7, 2017

@psd_martinb I noticed that MS problem a week ago and modified my script. I changed it to use $4 variable now instead of reading the MS history page. Been working good for a week now.

https://github.com/stevemillermac/MicrosoftSilverlightUpdate


Forum|alt.badge.img+6
  • Contributor
  • 24 replies
  • April 7, 2017

@millersc Awesome! Thank you :)


Forum|alt.badge.img+11
  • Author
  • Contributor
  • 33 replies
  • April 10, 2017

@millersc Thanks!


Forum|alt.badge.img+6

Got the updated script from guthub.

And get this error when running locally.

Jan 24, 2018, 8:41:35 AM

~/Documents/Casper Resources/Scripts/silverlight.sh

curl: (3) <url> malformed
hdiutil: attach failed - No such file or directory
hdiutil: detach failed - No such file or directory


Forum|alt.badge.img+10
  • New Contributor
  • 306 replies
  • January 24, 2018

@ktermin

This script should be run from the JAMF server and scoped out to the device.

I've been running this version for months without issues and $4 is still running 5.1.50901.0.

Steve


Forum|alt.badge.img+6

@millersc

Cool. I will test that way. Usually I run the script locally to troubleshoot.

Thanks for the heads up.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • January 24, 2018

@ktermin It can be run locally, but you can't just drop it as is into Terminal. To test it locally first, use the jamf binary. Example:

1sudo jamf runScript -script <script_name_including_extension> -path <path_to_script_minus_script_name> -p1 <parameter 4 string>

Just replace the items between the < & > brackets with the correct information.

Incidentally, @millersc should probably update his script to check for a string passed to $4 and fail with a more descriptive error message if one isn't passed. As it is, it's not downloading anything and hdiutil has no DMG to work with, which is why it's throwing that error.


Forum|alt.badge.img+6

It is installing version 5.1.50901.0.

This is the error it is outputting:

Script result: Microsoft Silverlight is not installed
Downloading the DMG
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

58 14.3M 58 8615k 0 0 9026k 0 0:00:01 --:--:-- 0:00:01 9026k
100 14.3M 100 14.3M 0 0 10.8M 0 0:00:01 0:00:01 --:--:-- 16.0M
Mounting the DMG
Installing Microsoft Silverlight
The mount point is disk2s2
ERROR: Microsoft Silverlight update unsuccessful, version remains at none.

Even though there is an error, it still installs but seems to be the old version. New version being Silverlight 5 Build 5.1.50907.0 Released June 13, 2017.

I read thru the thread and seems there was an issue but was fixed. Is this not the case? Thanks!


dstranathan
Forum|alt.badge.img+19
  • Valued Contributor
  • 569 replies
  • January 24, 2018

I also have 5.1.50901.0 installed which appears to be the most recent according to https://www.microsoft.com/getsilverlight/Get-Started/Install/Default


Forum|alt.badge.img+6

https://www.microsoft.com/getsilverlight/locale/en-us/html/Microsoft%20Silverlight%20Release%20History.htm#SL_5_1_50907


Forum|alt.badge.img+10
  • New Contributor
  • 306 replies
  • January 24, 2018

Microsoft has made updates to the Windows version, not the Mac version. It is still at 5.1.50901.0. I believe that is why your getting an error.

This is the result of the script from yesterday:

1Executing Policy Install Silverlight Latest
2Running script MicrosoftSilverlightUpdate.sh...
3Script exit code: 0
4Script result: Microsoft Silverlight is not installed
5Downloading the DMG
6% Total % Received % Xferd Average Speed Time Time Time Current
7Dload Upload Total Spent Left Speed
8
90 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
11
120 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
130 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
1412 14.3M 12 1835k 0 0 634k 0 0:00:23 0:00:02 0:00:21 918k
1545 14.3M 45 6762k 0 0 1739k 0 0:00:08 0:00:03 0:00:05 2257k
1679 14.3M 79 11.4M 0 0 2405k 0 0:00:06 0:00:04 0:00:02 2943k
17100 14.3M 100 14.3M 0 0 2731k 0 0:00:05 0:00:05 --:--:-- 3274k
18Mounting the DMG
19Installing Microsoft Silverlight
20The mount point is disk3s2
21SUCCESS: Microsoft Silverlight has been updated to version 5.1.50901.0

Forum|alt.badge.img
  • New Contributor
  • 1 reply
  • January 24, 2018

FYI - Microsoft no longer updates or supports Silverlight for Mac as of 12/31/2016.
Also, the last supported macOS version is 10.11.
https://www.microsoft.com/getsilverlight/locale/en-us/html/installation-win-SL5.html


Forum|alt.badge.img+4
  • New Contributor
  • 8 replies
  • March 23, 2018

Thank you iJake for the script. It worked like a charm.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings