Public/Policy.ps1

function Get-MgWindowsUpdateAutopatchPolicyBeta {
    <#
    .SYNOPSIS
    Gets current Windows Autopatch policy resources from the beta API.
    .DESCRIPTION
    Gets current Windows Autopatch policy resources from the beta API. 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 All
    Follows Microsoft Graph pagination links until all result pages are returned.
    .PARAMETER Count
    Requests the OData count annotation.
    .PARAMETER Expand
    Specifies related resources to include through OData $expand.
    .PARAMETER Filter
    Specifies an OData $filter expression.
    .PARAMETER OrderBy
    Specifies an OData $orderby expression.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER Query
    Specifies additional OData query parameters as key-value pairs.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .PARAMETER Skip
    Specifies the number of items to skip.
    .PARAMETER Top
    Specifies the maximum number of items requested from Microsoft Graph.
    .EXAMPLE
    PS> Get-MgWindowsUpdateAutopatchPolicyBeta `
        -Select id `
        -All
 
    Gets current Windows Autopatch policy resources from the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [string] $PolicyId,
        [string] $Filter,
        [string[]] $Select,
        [string[]] $Expand,
        [string[]] $OrderBy,
        [ValidateRange(1, 999)]
        [int] $Top,
        [ValidateRange(0, [int]::MaxValue)]
        [int] $Skip,
        [switch] $Count,
        [switch] $All,
        [hashtable] $Query
    )

    $path = if ($PolicyId) { "policies/$PolicyId" } else { 'policies' }
    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata -All:$All
}

function New-MgWindowsUpdateAutopatchPolicyBeta {
    <#
    .SYNOPSIS
    Creates a Windows Autopatch policy using the beta API.
    .DESCRIPTION
    Creates a Windows Autopatch policy using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER Body
    Specifies the Microsoft Graph request body.
    .EXAMPLE
    PS> $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.qualityUpdatePolicy'
        displayName = 'Patch Tuesday pilot'
        description = 'Pilot quality updates before broad deployment'
        approvalRules = @(
            @{
                '@odata.type' = (
                    '#microsoft.graph.windowsUpdates.qualityUpdateApprovalRule'
                )
                deferralInDays = 0
                classification = 'nonSecurity'
                cadence = 'outOfBand'
            }
        )
    }
    New-MgWindowsUpdateAutopatchPolicyBeta `
        -Body $body `
        -WhatIf
 
    Adapts the documented qualityUpdatePolicy example. Remove -WhatIf after
    reviewing the display name and approval rule.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [hashtable] $Body
    )

    if ($PSCmdlet.ShouldProcess('Windows Autopatch policies', 'Create beta policy')) {
        Invoke-MgWindowsUpdatesRequest -Method POST -Path 'policies' -Body $Body
    }
}

function Set-MgWindowsUpdateAutopatchPolicyBeta {
    <#
    .SYNOPSIS
    Updates a Windows Autopatch policy using the beta API.
    .DESCRIPTION
    Updates a Windows Autopatch policy using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER Body
    Specifies the Microsoft Graph request body.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .EXAMPLE
    PS> $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.qualityUpdatePolicy'
        displayName = 'Patch Tuesday pre-production'
        description = 'Quality update policy for pre-production validation'
        approvalRules = @(
            @{
                '@odata.type' = (
                    '#microsoft.graph.windowsUpdates.qualityUpdateApprovalRule'
                )
                deferralInDays = 0
                classification = 'nonSecurity'
                cadence = 'outOfBand'
            }
        )
    }
    $policyId = 'd39ad1ce-0123-4567-89ab-cdef01234567'
    Set-MgWindowsUpdateAutopatchPolicyBeta `
        -Body $body `
        -PolicyId $policyId `
        -WhatIf
 
    Adapts the documented qualityUpdatePolicy update example and previews the change.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [hashtable] $Body
    )

    if ($PSCmdlet.ShouldProcess($PolicyId, 'Update beta policy')) {
        Invoke-MgWindowsUpdatesRequest -Method PATCH -Path "policies/$PolicyId" -Body $Body
    }
}

function Remove-MgWindowsUpdateAutopatchPolicyBeta {
    <#
    .SYNOPSIS
    Deletes a Windows Autopatch policy using the beta API.
    .DESCRIPTION
    Deletes a Windows Autopatch policy using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .EXAMPLE
    PS> $policyId = '<policy-id>'
    Remove-MgWindowsUpdateAutopatchPolicyBeta `
        -PolicyId $policyId `
        -WhatIf
    Deletes a Windows Autopatch policy using the beta API. The example uses -WhatIf so the target and payload can be reviewed before making the change.
    #>

    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId
    )

    if ($PSCmdlet.ShouldProcess($PolicyId, 'Delete beta policy')) {
        Invoke-MgWindowsUpdatesRequest -Method DELETE -Path "policies/$PolicyId"
    }
}

function Get-MgWindowsUpdateApplicableCatalogBeta {
    <#
    .SYNOPSIS
    Gets policy applicable catalogs using the beta API.
    .DESCRIPTION
    Gets policy applicable catalogs using the beta API. 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 All
    Follows Microsoft Graph pagination links until all result pages are returned.
    .PARAMETER ApplicableCatalogId
    Specifies the Microsoft Graph identifier of the applicable catalog.
    .PARAMETER Expand
    Specifies related resources to include through OData $expand.
    .PARAMETER Filter
    Specifies an OData $filter expression.
    .PARAMETER OrderBy
    Specifies an OData $orderby expression.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER Query
    Specifies additional OData query parameters as key-value pairs.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .PARAMETER Top
    Specifies the maximum number of items requested from Microsoft Graph.
    .EXAMPLE
    PS> $policyId = '<policy-id>'
    Get-MgWindowsUpdateApplicableCatalogBeta `
        -PolicyId $policyId `
        -Select id `
        -All
 
    Gets policy applicable catalogs using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [string] $ApplicableCatalogId,

        [string] $Filter,
        [string[]] $Select,
        [string[]] $Expand,
        [string[]] $OrderBy,
        [ValidateRange(1, 999)]
        [int] $Top,
        [switch] $All,
        [hashtable] $Query
    )

    $path = "policies/$PolicyId/applicableCatalogs"
    if ($ApplicableCatalogId) {
        $path += "/$ApplicableCatalogId"
    }
    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata -All:$All
}

function Get-MgWindowsUpdateApplicableCatalogDeviceBeta {
    <#
    .SYNOPSIS
    Gets devices for a policy applicable catalog using the beta API.
    .DESCRIPTION
    Gets devices for a policy applicable catalog using the beta API. 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 All
    Follows Microsoft Graph pagination links until all result pages are returned.
    .PARAMETER ApplicableCatalogId
    Specifies the Microsoft Graph identifier of the applicable catalog.
    .PARAMETER Filter
    Specifies an OData $filter expression.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER Query
    Specifies additional OData query parameters as key-value pairs.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .PARAMETER Top
    Specifies the maximum number of items requested from Microsoft Graph.
    .EXAMPLE
    PS> $applicableCatalogId = '<applicable-catalog-id>'
    $policyId = '<policy-id>'
    Get-MgWindowsUpdateApplicableCatalogDeviceBeta `
        -ApplicableCatalogId $applicableCatalogId `
        -PolicyId $policyId `
        -Select id `
        -All
 
    Gets devices for a policy applicable catalog using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [string] $ApplicableCatalogId,

        [string] $Filter,
        [string[]] $Select,
        [ValidateRange(1, 999)]
        [int] $Top,
        [switch] $All,
        [hashtable] $Query
    )

    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    $path = "policies/$PolicyId/applicableCatalogs/$ApplicableCatalogId/devices"
    Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata -All:$All
}

function Get-MgWindowsUpdateApplicableContentBeta {
    <#
    .SYNOPSIS
    Gets applicable content for a Windows Autopatch policy using the beta API.
    .DESCRIPTION
    Gets applicable content for a Windows Autopatch policy using the beta API. 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 All
    Follows Microsoft Graph pagination links until all result pages are returned.
    .PARAMETER Expand
    Specifies related resources to include through OData $expand.
    .PARAMETER Filter
    Specifies an OData $filter expression.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER Query
    Specifies additional OData query parameters as key-value pairs.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .PARAMETER Top
    Specifies the maximum number of items requested from Microsoft Graph.
    .EXAMPLE
    PS> $policyId = '<policy-id>'
    Get-MgWindowsUpdateApplicableContentBeta `
        -PolicyId $policyId `
        -Select id `
        -All
 
    Gets applicable content for a Windows Autopatch policy using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [string] $Filter,
        [string[]] $Select,
        [string[]] $Expand,
        [ValidateRange(1, 999)]
        [int] $Top,
        [switch] $All,
        [hashtable] $Query
    )

    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    Invoke-MgWindowsUpdatesRequest -Method GET `
        -Path "policies/$PolicyId/applicableContent" `
        -Query $odata `
        -All:$All
}

function Get-MgWindowsUpdatePolicyApprovalBeta {
    <#
    .SYNOPSIS
    Gets policy approvals using the beta API.
    .DESCRIPTION
    Gets policy approvals using the beta API. 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 All
    Follows Microsoft Graph pagination links until all result pages are returned.
    .PARAMETER Expand
    Specifies related resources to include through OData $expand.
    .PARAMETER Filter
    Specifies an OData $filter expression.
    .PARAMETER PolicyApprovalId
    Specifies the Microsoft Graph identifier of the policy approval.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER Query
    Specifies additional OData query parameters as key-value pairs.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .PARAMETER Top
    Specifies the maximum number of items requested from Microsoft Graph.
    .EXAMPLE
    PS> $policyId = '<policy-id>'
    Get-MgWindowsUpdatePolicyApprovalBeta `
        -PolicyId $policyId `
        -Select id `
        -All
 
    Gets policy approvals using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [string] $PolicyApprovalId,

        [string] $Filter,
        [string[]] $Select,
        [string[]] $Expand,
        [ValidateRange(1, 999)]
        [int] $Top,
        [switch] $All,
        [hashtable] $Query
    )

    $path = "policies/$PolicyId/approvals"
    if ($PolicyApprovalId) {
        $path += "/$PolicyApprovalId"
    }
    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata -All:$All
}

function New-MgWindowsUpdatePolicyApprovalBeta {
    <#
    .SYNOPSIS
    Creates a policy approval using the beta API.
    .DESCRIPTION
    Creates a policy approval using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER Body
    Specifies the Microsoft Graph request body.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .EXAMPLE
    PS> $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.policyApproval'
        catalogEntryId = '1d8864c1-531f-4d5b-8225-8653ef4316d8'
        status = 'approved'
    }
    $policyId = 'd39ad1ce-0123-4567-89ab-cdef01234567'
    New-MgWindowsUpdatePolicyApprovalBeta `
        -Body $body `
        -PolicyId $policyId `
        -WhatIf
 
    Adapts the documented policyApproval example and previews approving one catalog entry.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [hashtable] $Body
    )

    if ($PSCmdlet.ShouldProcess($PolicyId, 'Create beta policy approval')) {
        Invoke-MgWindowsUpdatesRequest -Method POST `
            -Path "policies/$PolicyId/approvals" `
            -Body $Body
    }
}

function Set-MgWindowsUpdatePolicyApprovalBeta {
    <#
    .SYNOPSIS
    Updates a policy approval using the beta API.
    .DESCRIPTION
    Updates a policy approval using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER Body
    Specifies the Microsoft Graph request body.
    .PARAMETER PolicyApprovalId
    Specifies the Microsoft Graph identifier of the policy approval.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .EXAMPLE
    PS> $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.policyApproval'
        catalogEntryId = '1d8864c1-531f-4d5b-8225-8653ef4316d8'
        status = 'suspended'
    }
    $policyApprovalId = 'c03911a7-9876-5432-10ab-cdef98765432'
    $policyId = 'd39ad1ce-0123-4567-89ab-cdef01234567'
    Set-MgWindowsUpdatePolicyApprovalBeta `
        -Body $body `
        -PolicyApprovalId $policyApprovalId `
        -PolicyId $policyId `
        -WhatIf
 
    Adapts the documented policyApproval update example and previews suspending approval.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [string] $PolicyApprovalId,

        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [hashtable] $Body
    )

    if ($PSCmdlet.ShouldProcess($PolicyApprovalId, 'Update beta policy approval')) {
        Invoke-MgWindowsUpdatesRequest -Method PATCH `
            -Path "policies/$PolicyId/approvals/$PolicyApprovalId" `
            -Body $Body
    }
}

function Remove-MgWindowsUpdatePolicyApprovalBeta {
    <#
    .SYNOPSIS
    Deletes a policy approval using the beta API.
    .DESCRIPTION
    Deletes a policy approval using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER PolicyApprovalId
    Specifies the Microsoft Graph identifier of the policy approval.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .EXAMPLE
    PS> $policyApprovalId = '<policy-approval-id>'
    $policyId = '<policy-id>'
    Remove-MgWindowsUpdatePolicyApprovalBeta `
        -PolicyApprovalId $policyApprovalId `
        -PolicyId $policyId `
        -WhatIf
    Deletes a policy approval using the beta API. The example uses -WhatIf so the target and payload can be reviewed before making the change.
    #>

    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [string] $PolicyApprovalId
    )

    if ($PSCmdlet.ShouldProcess($PolicyApprovalId, 'Delete beta policy approval')) {
        Invoke-MgWindowsUpdatesRequest -Method DELETE `
            -Path "policies/$PolicyId/approvals/$PolicyApprovalId"
    }
}

function Get-MgWindowsUpdateRingBeta {
    <#
    .SYNOPSIS
    Gets Windows Autopatch policy rings using the beta API.
    .DESCRIPTION
    Gets Windows Autopatch policy rings using the beta API. 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 All
    Follows Microsoft Graph pagination links until all result pages are returned.
    .PARAMETER Expand
    Specifies related resources to include through OData $expand.
    .PARAMETER Filter
    Specifies an OData $filter expression.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER Query
    Specifies additional OData query parameters as key-value pairs.
    .PARAMETER RingId
    Specifies the Microsoft Graph identifier of the ring.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .PARAMETER Top
    Specifies the maximum number of items requested from Microsoft Graph.
    .EXAMPLE
    PS> $policyId = '<policy-id>'
    Get-MgWindowsUpdateRingBeta `
        -PolicyId $policyId `
        -Select id `
        -All
 
    Gets Windows Autopatch policy rings using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [string] $RingId,

        [string] $Filter,
        [string[]] $Select,
        [string[]] $Expand,
        [ValidateRange(1, 999)]
        [int] $Top,
        [switch] $All,
        [hashtable] $Query
    )

    $path = "policies/$PolicyId/rings"
    if ($RingId) {
        $path += "/$RingId"
    }
    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata -All:$All
}

function New-MgWindowsUpdateRingBeta {
    <#
    .SYNOPSIS
    Creates a Windows Autopatch policy ring using the beta API.
    .DESCRIPTION
    Creates a Windows Autopatch policy ring using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER Body
    Specifies the Microsoft Graph request body.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .EXAMPLE
    PS> $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.qualityUpdateRing'
        displayName = 'Ring 0 - IT devices'
        description = 'Validate updates before production rollout'
        includedGroupAssignment = @{
            '@odata.type' = (
                '#microsoft.graph.windowsUpdates.includedGroupAssignment'
            )
        }
        excludedGroupAssignment = @{
            '@odata.type' = (
                '#microsoft.graph.windowsUpdates.excludedGroupAssignment'
            )
        }
        deferralInDays = 5
        isPaused = $false
    }
    $policyId = 'd39ad1ce-0123-4567-89ab-cdef01234567'
    New-MgWindowsUpdateRingBeta `
        -Body $body `
        -PolicyId $policyId `
        -WhatIf
 
    Adapts the documented qualityUpdateRing creation example and previews the ring.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [hashtable] $Body
    )

    if ($PSCmdlet.ShouldProcess($PolicyId, 'Create beta policy ring')) {
        Invoke-MgWindowsUpdatesRequest -Method POST -Path "policies/$PolicyId/rings" -Body $Body
    }
}

function Set-MgWindowsUpdateRingBeta {
    <#
    .SYNOPSIS
    Updates a Windows Autopatch policy ring using the beta API.
    .DESCRIPTION
    Updates a Windows Autopatch policy ring using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER Body
    Specifies the Microsoft Graph request body.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER RingId
    Specifies the Microsoft Graph identifier of the ring.
    .EXAMPLE
    PS> $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.qualityUpdateRing'
        displayName = 'Pre-production'
        description = 'Pre-production validation ring'
        deferralInDays = 5
        isPaused = $true
        isHotpatchEnabled = $true
    }
    $policyId = 'd39ad1ce-0123-4567-89ab-cdef01234567'
    $ringId = 'c03911a7-9876-5432-10ab-cdef98765432'
    Set-MgWindowsUpdateRingBeta `
        -Body $body `
        -PolicyId $policyId `
        -RingId $ringId `
        -WhatIf
 
    Adapts the documented qualityUpdateRing update example and previews pausing
    the ring while enabling Hotpatch.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [string] $RingId,

        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [hashtable] $Body
    )

    if ($PSCmdlet.ShouldProcess($RingId, 'Update beta policy ring')) {
        Invoke-MgWindowsUpdatesRequest -Method PATCH `
            -Path "policies/$PolicyId/rings/$RingId" `
            -Body $Body
    }
}

function Remove-MgWindowsUpdateRingBeta {
    <#
    .SYNOPSIS
    Deletes a Windows Autopatch policy ring using the beta API.
    .DESCRIPTION
    Deletes a Windows Autopatch policy ring using the beta API. This command uses the Microsoft Graph beta endpoint; beta behavior and schemas can change without notice. Requires WindowsUpdates.ReadWrite.All in the active Microsoft Graph context.
    .PARAMETER PolicyId
    Specifies the Microsoft Graph policy identifier.
    .PARAMETER RingId
    Specifies the Microsoft Graph identifier of the ring.
    .EXAMPLE
    PS> $policyId = '<policy-id>'
    $ringId = '<ring-id>'
    Remove-MgWindowsUpdateRingBeta `
        -PolicyId $policyId `
        -RingId $ringId `
        -WhatIf
    Deletes a Windows Autopatch policy ring using the beta API. The example uses -WhatIf so the target and payload can be reviewed before making the change.
    #>

    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
    param(
        [Parameter(Mandatory)]
        [string] $PolicyId,

        [Parameter(Mandatory)]
        [string] $RingId
    )

    if ($PSCmdlet.ShouldProcess($RingId, 'Delete beta policy ring')) {
        Invoke-MgWindowsUpdatesRequest -Method DELETE -Path "policies/$PolicyId/rings/$RingId"
    }
}