private/Find-UpdateMetadata.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Find-UpdateMetadata {
    <#
        Get metadata for all updates/all builds
    #>

        [CmdletBinding()]
        Param()

    Begin {
        # link to JSON with the list of KB articles with updates
        $startKBarticle = 'https://support.microsoft.com/app/content/api/content/asset/en-us/4000816'
    }

    Process {
        (   (Invoke-WebRequest -Uri $startKBarticle).Content |
            ConvertFrom-Json
        ).Links |
        Select-Object `
            articleId,
            Text,
            @{  Name = 'Version'
                Expression = {
                    ($_.Text -replace '(?x) ^.* Builds? \s+ ([.0-9]+) .* $', '$1') -as [Version]
            }
        } |
        Where-Object Version
    }

    End {}

}