locked
download windows patch files(patchid like KBxxxxx) and save it into local disk using powerShell RRS feed

  • Question

  • Dear Team,

    Greetings !

    I am very new to PowerShell i would to make script to download patch files using Patch ID (KBxxxxx) and save it local disk to install whenever its required.

    i am using powershell version 2.0

    Request you to kindly help me.

    Thanking in advance.

    Thursday, October 12, 2017 7:54 AM

Answers

  • I know this is a super old post, but wanted to let you and Google know that it's possible. I kept seeing this post come up and the solutions provided were not helpful for me.

    After additional searching, I found what I needed and built this script which is cross platform, no ActiveX required, no IE. etc.

    Here is Save-KBFile

    https://gist.github.com/potatoqualitee/b5ed9d584c79f4b662ec38bd63e70a2d

    • Marked as answer by jrv Thursday, July 4, 2019 10:15 PM
    Thursday, July 4, 2019 10:09 PM

All replies

  • Thanks !!

    i have raised request in scriptcenter site.

    Regards

    Senthil
    Thursday, October 12, 2017 9:06 AM
  • Hi,

    I'm checking how the issue is going, was your issue resolved?

    And if the replies as above are helpful, we would appreciate you to mark them as answers, and if you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.

    Appreciate for your feedback.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, October 13, 2017 9:23 AM
  • Hi Albert,

    Thanks for your kind support.

    still i haven't find the solution, waiting for the kind response from team.

    Best Regards,

    Senthil

    Monday, October 23, 2017 7:55 AM
  • Hi Senthil,

    Based on my research, I'd like to explain that this requirement might be too complex to achieve because one KB might contains multiple packages and it also be divided into different OSs and different platforms (x86 or x64). The following screenshot for your reference:

    In this case, I recommend you could just download the specific needed KB manually. Also you could have a try with WSUS server which is designed to manage Windows Updates.

    If you have any updates during this process, please feel free to let me know.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, October 24, 2017 7:53 AM
  • See: https://blogs.technet.microsoft.com/heyscriptingguy/2012/11/08/use-a-powershell-module-to-run-windows-update/

    For  WMF 5 and later:

    find-module PSWindowsUpdate | Install-Module

    If you had actually followed the links I posted above you would have found this module.

    Get-WUInstall -KBArticleID KB2267602 -DownloadOnly

    Please learn to use the Gallery and help as it will save you a lot of wasted time.


    \_(ツ)_/

    Tuesday, October 24, 2017 8:32 AM
  • Thank you Albert for your response.

    yes, you are right we can filter with machine and OS i think i am also trying my best to get done..

    Thank you for your time for this investigation.

    please let me know if you found any update on this.

    Best Regards,
    Senthil

    Tuesday, October 24, 2017 9:25 AM
  • Hi Moderator, 

    Thank you for your kind response.

    you are correct we can use the above mentioned command to download particular in WMF 5.

    but unfortunately i am using WMF 2 only. Request you to kindly give some suggestion.

    Best Regards,
    Senthil

    Tuesday, October 24, 2017 9:27 AM
  • You should no longer be using PS 2 as it is  a security risk and is no longer supported by Microsoft.

    The module will work on PS 2.  Download and save on a WMF 5 system and copy to target system or just download using the instructions in the article.


    \_(ツ)_/

    Tuesday, October 24, 2017 9:32 AM
  • Thank you for your kind response.

    you are correct we can do that way.

    but due to some project constraint i could not do that as of now.

    i need to use PS 2 to only for download patch.

    Thank you for your time and support.

    please suggest if you have any idea to do.

    i am trying with below code to download and save the patch files,but its not working.

      $url = "https://www.microsoft.com/en-us/download/confirmation.aspx?id=40854" 
        $path = "C:\src\" 
       # param([string]$url, [string]$path) 
          
        if(!(Split-Path -parent $path) -or !(Test-Path -pathType Container (Split-Path -parent $path))) { 
          $path = Join-Path $pwd (Split-Path -leaf $path) 
        } 
          
        "Downloading [$url]`nSaving at [$path]" 
        $client = new-object System.Net.WebClient 
       # $client.DownloadFile($url, $path) 
        $client.DownloadData($url, $path) 
          
        $path

    Best Regards,

    senthil

    Tuesday, October 24, 2017 9:42 AM
  • You miss my point.  The module works in PS2.  Just read the article and follow the download instructions.

    https://blogs.technet.microsoft.com/heyscriptingguy/2012/11/08/use-a-powershell-module-to-run-windows-update/

    You cannot download from the catalog as it is protected. S does not want you to do this for many reasons so they have mde it impossible to do.

    The Windows Update object is designed to use to download by KB, Category etc.


    \_(ツ)_/

    Tuesday, October 24, 2017 9:48 AM
  • Thank you for your kind response.

    apologies for any misunderstanding for my previous comments.

    I have gone through the article. but that is not matching my solution.

    The Windows Update object is designed to use to download by KB, Category etc. as you said, yes i am looking to download using KB only.

    Thank you for your kind support and time.

    Request to kindly suggest. if you have any idea on this


    Best Regards,
    Senthil

     
    Tuesday, October 24, 2017 10:17 AM
  • It downloads by KB article number.

    You have not read and understood any of this. Please find someone to help you. There is nothing more we can do to help you.

     


    \_(ツ)_/

    • Marked as answer by Velsenthil Tuesday, October 24, 2017 10:52 AM
    • Unmarked as answer by Velsenthil Tuesday, October 24, 2017 10:52 AM
    Tuesday, October 24, 2017 10:43 AM
  • Thank you for your response.

    i understood, could you please guide me to fix this.

    Best Regards,
    Senthil
    Tuesday, October 24, 2017 10:53 AM
  • Hi,

    I am checking how the issue is going, if you still have any questions, please feel free to contact us.

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.

    Appreciate for your feedback.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, October 27, 2017 3:08 AM
  • Thanks for kind support Albert.

    sorry to say still i am stuck in download patch files using KB article number request you to kindly guide me.

    Thanks and regards,
    Senthil
    Monday, October 30, 2017 9:08 AM
  • I know this is a super old post, but wanted to let you and Google know that it's possible. I kept seeing this post come up and the solutions provided were not helpful for me.

    After additional searching, I found what I needed and built this script which is cross platform, no ActiveX required, no IE. etc.

    Here is Save-KBFile

    https://gist.github.com/potatoqualitee/b5ed9d584c79f4b662ec38bd63e70a2d

    • Marked as answer by jrv Thursday, July 4, 2019 10:15 PM
    Thursday, July 4, 2019 10:09 PM
  • I know this is a super old post, but wanted to let you and Google know that it's possible. I kept seeing this post come up and the solutions provided were not helpful for me.

    After additional searching, I found what I needed and built this script which is cross platform, no ActiveX required, no IE. etc.

    Here is Save-KBFile

    https://gist.github.com/potatoqualitee/b5ed9d584c79f4b662ec38bd63e70a2d

    Very nice job.  Many will find it quite useful.


    \_(ツ)_/

    Thursday, July 4, 2019 10:15 PM