Download All Microsoft Management Packs for SCOM 2007, R2 and 2012 in Bulk with PowerShell

Just last week Daniel Savage published a list on TechNet Wiki with all management packs for OpsMgr 2007, R2 and 2012. A couple of days later Stefan Stranger wrote Finding Management Packs from Microsoft Download website using PowerShell and provided a small PowerShell script that provides a list with the management packs from that site and links to them. After reading that post I was wondering wouldn’t be cool if you get the names of all management packs and their links and download all of them with their guides also. And when you download them to be able to organize them in structure that includes the name of the MP and its version. Instead of writing to Stefan I’ve said to myself – What the hell I will try to make that script. I do not have any big experience with PowerShell and it was not easy to built the script but because I’ve managed to create this proves that PowerShell is easy to learn but you have to be persistent. During the creation of the script I’ve noticed that some of the links on the page were incorrect so I’ve corrected them.

In short the script grabs the names and the links for all management packs on the site. Than it goes trough every MP link. From every MP page gets the version of it and all download links (msi, guides and etc.). Than creates a directory for that MP and subdirectory with the version number and downloads all files in it. The script requires PowerShell v3.

Here is the script:

   1: #Get list of all Management packs and their links from Technet Wiki

   2: #Thanks to Stefan Stranger

   3: $allmpspage = Invoke-WebRequest -Uri ""

   4: $mpslist = $allmpspage.Links | Where-Object {($_.href -like "**download*") -and ($_.outerText -notlike "*Link to download page*") -and ($_.InnerHTML -like "*This link*")} |

   5: Select @{Label="Management Pack";Expression={$_.InnerText}}, @{Label="Download Link";Expression={$_.href}}


   7: #Directory to save the downloaded management packs. Make sure it is created first before running the script

   8: $dirmp = "D:\MPs\"


  10: #go trough every MP

  11: foreach ($mp in $mpslist)

  12: {

  13: #get MP link

  14: $mplink = $mp.'Download Link'


  16: #get MP name

  17: $mpname = $mp.'Management Pack'

  18: Write-Host "MP Name:" $mpname

  19: Write-Host "MP Link:" $mplink


  21: #Read MP page

  22: $mppage = Invoke-WebRequest -Uri "$mplink"


  24: #Find all download links on the page (mp, guide and etc.). $_.href cannot be used beacuse some of the links require conformation before download

  25: $dws = $mppage.Links | Where-Object {($_.'bi:fileurl' -like "**") } | Select @{Label="Download Link";Expression={$_.'bi:fileurl'}}


  27: #Find the version number of the MP on its page

  28: $version = $mppage.ParsedHtml.getElementsByTagName("td") | Where "classname" -contains "col2" | Select -ExpandProperty InnerText


  30: #Remove character ? in fron of MP version. For some reason some versions of mps start with ?

  31: $version = $version.Replace("?","")


  33: #Remove / character from MP name if contains it beacuse can create unneeded directories

  34: $mpname = $mpname.Replace("/","")

  35: Write-Host "MP Version:" $version

  36: Write-Host "Download Links:" $dws


  38: #Create directory with the Name of the MP and subdirecotory with the version of the MP

  39: New-Item -ItemType directory -Path $dirmp\$mpname\$version


  41: #Get the array of found download links

  42: $dws = $dws.'Download Link'


  44: #Get trough every download link

  45: foreach ($dw in $dws)

  46: {

  47: #assign download link to $source variable

  48: $source = $dw


  50: #Get the name of the file that will be downloaded

  51: $Filename = [System.IO.Path]::GetFileName($source)


  53: #Set directory where the file to be downloaded

  54: $dest = "$dirmp\$mpname\$version\$Filename"


  56: #initiate client for download

  57: $wc = New-Object System.Net.WebClient


  59: #download the file and put it in the destination directory

  60: $wc.DownloadFile($source, $dest)

  61: }


  63: #empy line

  64: Write-Host

  65: }

You can download it from TechNet Gallery also.

Once again thanks to Stefan Stranger.

11 thoughts on “Download All Microsoft Management Packs for SCOM 2007, R2 and 2012 in Bulk with PowerShell

  1. just a note, when you run the script from Windows server 2008 R2 or 2012 make sure IE enhanced security configuration is off or add the web site to the trusted web site zones otherwise the script will popup a warning box about the site is not being trusted.

  2. Looks like Microsoft changed the page layout on to use javascript and now the script fails on the $version.replace() method since the parsed html is no longer matching correctly on the new page.

    Was awesome while it lasted.

  3. Stanislav, I’m working with the newest version of the script and trying to use it on a Windows 2012 R2 system. I’ve turned off IE enhanced security configuration and tried a variety of articles to allow the cookies but I am still getting prompted on each MP with the windows security warning on cookies. Do you have any other recommendations on this?

  4. Hi Cam,
    Yes I am aware of this issue. Microsoft decided to put cookies on download links. Do not have solution yet unfortunately. I have one idea that I haven’t tried. Will try it in the next days to see if I will succeed.

  5. Thank you Stanislav! I am attempting to use this as part of a PowerShell process that I’m developing to synchronize management packs between different management groups. I hope that we can find a way to get past the cookie issue!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.