Public/Types.ps1
|
function Get-MgWindowsUpdateTypeBeta { <# .SYNOPSIS Gets the documented Microsoft Graph beta Device Updates resource type catalog. .DESCRIPTION Gets the documented Microsoft Graph beta Device Updates resource type catalog. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.Read.All or WindowsUpdates.ReadWrite.All in the active Microsoft Graph context. .PARAMETER TypeName Specifies a documented Windows Updates beta resource or complex type name. .EXAMPLE PS> Get-MgWindowsUpdateTypeBeta -TypeName qualityUpdateFilter | Format-List * Displays the catalog entry for the qualityUpdateFilter beta type, including whether it is abstract and constructible. #> [CmdletBinding()] param( [ArgumentCompleter({ param($commandName, $parameterName, $wordToComplete) $null = $commandName, $parameterName Get-MgWindowsUpdateTypeCatalog | Where-Object Name -Like "$wordToComplete*" | ForEach-Object Name })] [ValidateScript({ $knownNames = (Get-MgWindowsUpdateTypeCatalog).Name if ($_ -notin $knownNames) { throw "'$_' isn't a documented Device Updates beta type." } $true })] [string[]] $TypeName ) $catalog = Get-MgWindowsUpdateTypeCatalog if ($TypeName) { return $catalog | Where-Object Name -In $TypeName } $catalog } function New-MgWindowsUpdateObjectBeta { <# .SYNOPSIS Creates an OData-typed request object for a documented Device Updates beta type. .DESCRIPTION Creates an OData-typed request object for a documented Device Updates beta type. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. This command does not issue a Microsoft Graph request. .PARAMETER Property Specifies properties to add to the typed request object. .PARAMETER TypeName Specifies a documented Windows Updates beta resource or complex type name. .EXAMPLE PS> $rollout = New-MgWindowsUpdateObjectBeta ` -TypeName dateDrivenRolloutSettings ` -Property @{ startDateTime = '2026-11-15T18:00:00Z' } $rollout Builds a typed date-driven rollout settings object without manually spelling the Microsoft Graph namespace. #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseShouldProcessForStateChangingFunctions', '', Justification = 'Constructs a local request object and does not change remote state.' )] [CmdletBinding()] [OutputType([System.Collections.Specialized.OrderedDictionary])] param( [Parameter(Mandatory)] [ArgumentCompleter({ param($commandName, $parameterName, $wordToComplete) $null = $commandName, $parameterName Get-MgWindowsUpdateTypeCatalog | Where-Object { $_.Constructible -and $_.Name -Like "$wordToComplete*" } | ForEach-Object Name })] [ValidateScript({ $definition = Get-MgWindowsUpdateTypeCatalog | Where-Object Name -EQ $_ if (-not $definition -or -not $definition.Constructible) { throw "'$_' isn't a constructible Device Updates beta type." } $true })] [string] $TypeName, [hashtable] $Property = @{} ) if ($Property.ContainsKey('@odata.type')) { throw "Don't include '@odata.type' in -Property; use -TypeName." } $definition = Get-MgWindowsUpdateTypeCatalog | Where-Object Name -EQ $TypeName $body = [ordered] @{ '@odata.type' = "#$($definition.ODataType)" } foreach ($entry in $Property.GetEnumerator()) { $body[$entry.Key] = $entry.Value } $body } function New-MgWindowsUpdateFilterBeta { <# .SYNOPSIS Creates a typed driver, quality, or remediation Windows update filter. .DESCRIPTION Creates a typed driver, quality, or remediation Windows update filter. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. This command does not issue a Microsoft Graph request. .PARAMETER Cadence Specifies the quality update cadence. .PARAMETER Classification Specifies the quality update classification. .PARAMETER Driver Specifies the driver. .PARAMETER Quality Specifies the quality. .PARAMETER Remediation Creates a remediation update filter instead of a quality update filter. .PARAMETER RemediationType Specifies the remediation update type. .EXAMPLE PS> $filter = New-MgWindowsUpdateFilterBeta ` -Cadence monthly ` -Classification security $filter Builds a typed monthly security quality-update filter for use in a policy or deployment request body. #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseShouldProcessForStateChangingFunctions', '', Justification = 'Constructs a local request object and does not change remote state.' )] [CmdletBinding(DefaultParameterSetName = 'Quality')] [OutputType([System.Collections.IDictionary])] param( [Parameter(Mandatory, ParameterSetName = 'Driver')] [switch] $Driver, [Parameter(ParameterSetName = 'Quality')] [switch] $Quality, [Parameter(Mandatory, ParameterSetName = 'Remediation')] [switch] $Remediation, [Parameter(ParameterSetName = 'Quality')] [ValidateSet('monthly', 'outOfBand', 'unknownFutureValue')] [string] $Cadence = 'monthly', [Parameter(ParameterSetName = 'Quality')] [ValidateSet('all', 'security', 'nonSecurity', 'unknownFutureValue')] [string] $Classification = 'all', [Parameter(ParameterSetName = 'Remediation')] [ValidateSet('inPlaceUpgrade', 'unknownFutureValue')] [string] $RemediationType = 'inPlaceUpgrade' ) $null = $Driver, $Quality, $Remediation switch ($PSCmdlet.ParameterSetName) { 'Driver' { New-MgWindowsUpdateObjectBeta -TypeName driverUpdateFilter } 'Remediation' { New-MgWindowsUpdateObjectBeta -TypeName remediationUpdateFilter -Property @{ remediationType = $RemediationType } } default { New-MgWindowsUpdateObjectBeta -TypeName qualityUpdateFilter -Property @{ cadence = $Cadence classification = $Classification } } } } |