我想自动化为 NAV 和 BC 下载最新 CU 的过程。我编写了 powershell 脚本,但仍然需要部分如何从该页面下载 zip 文件(https://www.microsoft.com/en-us/download/details。 aspx?id=58275 )
这是我到目前为止写的代码:
$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