0

I want to automate process of downloading newest CU for NAV and BC.I wrote powershell script, but still need part how to donwload zip file from this page (https://www.microsoft.com/en-us/download/details.aspx?id=58275)

This is the code that I wrote so far:

$FeedUrl = "https://support.microsoft.com/app/content/api/content/feeds/sap/en-gb/dea12e4a-4dd3-35e1-2577-45df252a2b9c/atom"
$FeedFilePath = "C:\Test\Feed.xml"
$ArticlePath = "C:\Test\Article.html"
$DownloadPagePath = "C:\Test\Download.html"

Download_File -Url $FeedUrl -FileName $FeedFilePath

[xml]$Content = Get-Content $FeedFilePath 
$Feed = $Content.feed
$SearchString = "Cumulative Update * for Microsoft Dynamics NAV 2018 *"

foreach($item in $Feed.entry){
    if($item.title -like $SearchString){
        Download_File -Url $item.link.href -FileName $ArticlePath
        $Article = Get-Content $ArticlePath | Out-String
        $endPos = 1                
        $startPos = $Article.IndexOf('http://www.microsoft.com/downloads/details.aspx?familyid=', $endPos)
        $endPos = $Article.IndexOf('\"', $startPos)
        $DownloadUrl = $Article.Substring($startPos, $endPos - $startPos)      
        break             
    }
}
Download_File -Url $DownloadUrl -FileName $DownloadPagePath

1 Answers1

0

Have you seen this?

http://www.waldo.be/2016/12/09/automate-downloads-of-cumulative-updates/

I also wonder why you need this? I think it's easier to pull docker images. Just if you do not need the installation media.

bLuB
  • 1
  • 1
  • 1