Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > Downloading SharePoint Patches with PowerShell
December 08
Downloading SharePoint Patches with PowerShell

I’ve been known to patch a SharePoint server here and there. Once in a while, when I’m on a customer server its Internet Explorer security settings will prevent me from being able to download a patch. I’ll go to my favorite patch list, or, and pick the patch I want. But when it comes down to getting the patch the IE security settings will prevent me from actually downloading said patch. Sadness ensues. I’ve had to do various dances to get the patches and recently I’ve started leveraging PowerShell more and more to do so. After a conversation with Jason Himmelstein I agreed to publish the PowerShell I use. Jason promised me you wouldn’t laugh. So you can’t laugh.

I also made a video of how to use it.


The Usage

I packaged this as a function, Get-TKMSKBDownload, and while it’s in a module, you can easily paste it into any existing module file you might already be using.

To use this function download TKDownloadFile.psm1.txt. Remove the “.txt” at the end to rename it to TKDownloadFile.psm1, Rename-Item .\TKDownloadfile.psm1.txt .\TKDownloadFile.psm1. Then Import it into your PowerShell session with Import-Module TKDownloadFile to let it know it’s there.


I have lovingly provided some Help and Examples to help you use it. In trying to address all of the situations where I’ve done this, I made sure the function worked with either details.aspx and confirmation.aspx URLs for the download link.


To use it, go to my patches page and click the Download link for the patch you want. Then copy that URL out of your browser and paste it after the function, like in the example:

Get-TKMSKBDownload -url

It will download the patch into your current directory. It should look like this when it runs:


After the file is downloaded you can run it and patch your SharePoint server.

I won’t paste all the code in this blog post, (download it here) but I do want to highlight a couple of pieces of it. First, this is the line I use to get the direct link to the patch download, where $url is the link from the patches page:

$downloadurl = ((Invoke-WebRequest -UseBasicParsing -Uri $url).links | Where-Object -Property data-bi-cN -Like -Value "click here to download manually" | select -First 1).href

Before I wrote this PowerShell I had a couple of instances where I needed the direct link to the patch. I had had to use the Developer Tools in Chrome to find the URL in the Microsoft Download web page. I was able to use that information to craft the line above. If you’re curious, you can start with the part inside of the parenthesis (Invoke-WebRequest -UseBasicParsing -Uri $url) and see how the page is loaded as an object by PowerShell. There is some interesting stuff in there.

The other part I needed was the name of the file to save. That’s part of the $downloadurl object, so I used this PowerShell to put off the file name, which is everything after the final / character, plus 1 so we don’t get the / itself:

$file = $downloadurl.Substring($downloadurl.LastIndexOf("/") + 1)

With those two pieces of information I’m able to pull the patch down and save it.

Invoke-WebRequest -UseBasicParsing -Uri $downloadurl -OutFile $file

As always, I had a couple of people look this code. Thanks to Shane Young and Jeff Hicks for all of that. Jeff had some great ideas for a v2 of this, like being able to specify a download directory, or backgrounding the download job. All good ideas, but I didn’t want to delay the publication of this blog post to implement them. If I keep using this module I may add them later. If I do, I’ll update this blog post.

Once again, if you’d like to see all of this magic in action, you can watch my HowTo video on YouTube.





Beneficial Write-up, My business is an enormous believer with placing reviews with web-sites to help allow blog site internet writers are aware that they’ve added in anything effective to help online! ufabet168
 on 11/8/2023 5:25 AM


I'd state which this can be a an excellent publish of the excellent individual, i am very happy to observe this particular. thc vape pen italia
 on 11/8/2023 7:06 AM

Re: Downloading SharePoint Patches with PowerShell

Many thanks with regard to supplying current improvements concerning the issue, We anticipate study much more.The Ultimate Guide to a Clean and Healthy Commercial Business in Calgary, Alberta
 on 11/9/2023 8:30 AM

Re: Downloading SharePoint Patches with PowerShell

Really good write-up, Appreciate it intended for giving That expertise. Excellently published document, but only if many blog writers made available identical higher level of information since you, the online world is a significantly better area. You need to thanks!ufabet1688
 on 11/11/2023 1:45 AM


Whoa! Precisely what a close look opener this specific article have been to me. A lot loved, added, My spouse and i can’t loose time waiting for additional! branded golf umbrellas
 on 11/25/2023 3:55 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.


Body *

Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person


Want a message when I reply to your comment? Put your Twitter handle here.