Private/Get-MgWindowsUpdatesQuery.ps1

function Get-MgWindowsUpdatesQuery {
    [CmdletBinding()]
    [OutputType([Collections.Specialized.OrderedDictionary])]
    param(
        [Parameter(Mandatory)]
        [Collections.IDictionary] $BoundParameters
    )

    $mapping = [ordered]@{
        Filter = '$filter'
        Select = '$select'
        Expand = '$expand'
        OrderBy = '$orderby'
        Search = '$search'
        Top = '$top'
        Skip = '$skip'
        Count = '$count'
    }

    $query = [ordered]@{}
    foreach ($parameterName in $mapping.Keys) {
        if ($BoundParameters.Keys -contains $parameterName) {
            $query[$mapping[$parameterName]] = $BoundParameters[$parameterName]
        }
    }

    if ($BoundParameters.Keys -contains 'Query') {
        foreach ($entry in $BoundParameters.Query.GetEnumerator()) {
            $key = [string] $entry.Key
            if (-not $key.StartsWith('$')) {
                $key = '$' + $key
            }
            $query[$key] = $entry.Value
        }
    }

    return $query
}