markus2016
Goto Top

Powershell "downloadInformation" Microsoft Update-Katalog auslesen

Hallo zusammen,

ich versuche gerade Informationen zu Updates aus dem Microsoft Update-Katalog mit Powershell auszulesen.

Bis jetzt schaut dies so aus:
[String]$KB_Article = "4554364"  
[string] $Filter = $(switch ([IntPtr]::Size){ 4 {'x86'}; 8 {'x64'} })  

$KB_Obj = Invoke-WebRequest -Uri "http://www.catalog.update.microsoft.com/Search.aspx?q=KB$($KB_Article)"  

$KB_UpdateIDs = $KB_Obj.Links | Where-Object {

$_.OuterHTML -match ( "(?=.*" + ( $Filter -join ")(?=.*" ) + ")" )  

} | ForEach-Object {

$_.ID.Replace('_link','')  

}   

ForEach ( $KB_UpdateID in $KB_UpdateIDs )
{

    $Post = @{ Size = 0; UpdateID = $KB_UpdateID; UpdateIDInfo = $KB_UpdateID } | ConvertTo-Json -Compress
    $PostBody = @{ UpdateIDs = "[$Post]" }  
            
}

$Content = Invoke-WebRequest -Uri "http://www.catalog.update.microsoft.com/DownloadDialog.aspx" -Method Post -Body $PostBody | Select-Object -ExpandProperty Content  

            $Update = New-Object -TypeName PSObject -Property @{
            'KB Article' = $KB_Article  
            'Title' = [regex]::Match($Content, '(?s)(?<=_C1_)(.+?)(?=<\/td>)').value.split('>')[-1].trim()  
            'Architecture' = $Filter   
            'DownloadLink' = [regex]::Match($Content, "(http[s]?\://download\.windowsupdate\.com\/[^\'\""""]*)").value  
            } 

$Update | Select 'KB Article', Title, Architecture, DownloadLink | Format-List  

Im $Content des Updates ist noch folgender Abschnitt enthalten:
    <script language="javascript" type="text/javascript">    
        // Writes the eula and file info arrays
        var downloadInformation = new Array();
downloadInformation = new Object();
downloadInformation.updateID ='fb807d74-2673-4c38-975e-90920bfdbd64';  
downloadInformation.isHotFix =false;
downloadInformation.enTitle ='2020-03 Cumulative Update for Windows 10 Version 1903 for x64-based Systems (KB4554364)';  
downloadInformation.sizeLanguage ='';  
downloadInformation.files = new Array();
downloadInformation.files = new Object();
downloadInformation.files.url = 'http://download.windowsupdate.com/c/msdownload/update/software/updt/2020/03/windows10.0-kb4554364-x64_0037f0861430f0d9a5cea807b46735c697a82d0c.msu';  
downloadInformation.files.digest = 'ADfwhhQw8NmlzqgHtGc1xpeoLQw=';  
downloadInformation.files.architectures = 'AMD64';  
downloadInformation.files.languages = 'all';  
downloadInformation.files.longLanguages = 'all';  
downloadInformation.files.fileName = 'windows10.0-kb4554364-x64_0037f0861430f0d9a5cea807b46735c697a82d0c.msu';  
downloadInformation.files.defaultFileNameLength = 175;
downloadInformation.allFilesExist = false;
var minFilePathLength =138;
var eulaInfo =  new Array();
var eulaInfo = '';  

Da dort alle Informationen zum Update enthalten sind, würde ich diesen Abschnitt gerne nutzen.
Dies bekomme ich aber leider nicht hin.

Könnt Ihr mir hierbei bitte behilflich sein.
Ich Blick das grad nicht. Mein letzter Versuch bevor mich mein Hirn verlassen hat.
'FileName' = [regex]::Match($Content, '(downloadInformation.files.fileName =?)(?+)').value.split("'").trim()  

Vielen Dank und Schöne Grüße

Markus

Content-Key: 564596

Url: https://administrator.de/contentid/564596

Printed on: April 26, 2024 at 03:04 o'clock

Mitglied: 143728
Solution 143728 Apr 12, 2020 updated at 07:17:25 (UTC)
Goto Top
Naja, in deinem Regex sind ja auch massive Fehler eingebaut ...
https://tio.run/##vVRtb9MwEP7eX2FVSGmBJE6TNu0g7IUBmyiDCdg@jIEc55J4OE6Jna ...

Für den Filename:
[regex]::match($content,"(?is)(?<=fileName\s*=\s*')[^']+").Value  

Happy easter and stay healthy.
c.
Member: Markus2016
Markus2016 Apr 12, 2020 at 10:10:16 (UTC)
Goto Top
Hallo cabrinha,

vielen lieben Dank für Deine Hilfe und den Link.

Ich werde mir das Thema "pattern" und die "character classes" wohl nochmal anschauen dürfen. face-wink

Frohe Ostern und bleib gesund.

Schöne Grüße
Markus