Public/Settings.ps1

function Get-MgWindowsUpdateTenantSettingBeta {
    <#
    .SYNOPSIS
    Gets tenant-level Windows Autopatch settings using the beta API.
    .DESCRIPTION
    Gets tenant-level Windows Autopatch settings 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 Expand
    Specifies related resources to include through OData $expand.
    .PARAMETER Query
    Specifies additional OData query parameters as key-value pairs.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .EXAMPLE
    PS> Get-MgWindowsUpdateTenantSettingBeta `
        -Select id
 
    Gets tenant-level Windows Autopatch settings using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [string[]] $Select,
        [string[]] $Expand,
        [hashtable] $Query
    )

    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    Invoke-MgWindowsUpdatesRequest -Method GET -Path 'tenantSettings' -Query $odata
}

function Set-MgWindowsUpdateTenantSettingBeta {
    <#
    .SYNOPSIS
    Updates tenant-level Windows Autopatch settings using the beta API.
    .DESCRIPTION
    Updates tenant-level Windows Autopatch settings 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.tenantSetting'
        areDataProcessorServiceForWindowsFeaturesEnabled = $true
    }
    Set-MgWindowsUpdateTenantSettingBeta `
        -Body $body `
        -WhatIf
 
    Adapts the documented tenantSetting update that enables Data Processor Service
    for Windows features. Remove -WhatIf after reviewing the tenant-level change.
    #>

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

    if ($PSCmdlet.ShouldProcess('Windows Autopatch tenant settings', 'Update beta settings')) {
        Invoke-MgWindowsUpdatesRequest -Method PATCH -Path 'tenantSettings' -Body $Body
    }
}

function Get-MgWindowsUpdateMdmAppSettingBeta {
    <#
    .SYNOPSIS
    Gets MDM application settings for Windows Autopatch using the beta API.
    .DESCRIPTION
    Gets MDM application settings for Windows Autopatch 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 MdmAppId
    Specifies the Microsoft Graph identifier of the mdm app.
    .PARAMETER Select
    Specifies properties to include through OData $select.
    .EXAMPLE
    PS> Get-MgWindowsUpdateMdmAppSettingBeta `
        -Select id
 
    Gets MDM application settings for Windows Autopatch using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination.
    #>

    [CmdletBinding()]
    param(
        [guid] $MdmAppId,
        [string[]] $Select
    )

    $path = if ($MdmAppId -and $MdmAppId -ne [guid]::Empty) {
        "tenantSettings/mdmAppSettings/$MdmAppId"
    }
    else {
        'tenantSettings/mdmAppSettings'
    }
    $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters
    Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata
}

function New-MgWindowsUpdateMdmAppSettingBeta {
    <#
    .SYNOPSIS
    Creates an MDM application setting for Windows Autopatch using the beta API.
    .DESCRIPTION
    Creates an MDM application setting for Windows Autopatch 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 IsHotpatchEnabled
    Specifies the is hotpatch enabled.
    .PARAMETER MdmAppId
    Specifies the Microsoft Graph identifier of the mdm app.
    .EXAMPLE
    PS> $mdmAppId = [guid] '6e8fb67d-ac92-5b14-8d6d-3299f92da00c'
    New-MgWindowsUpdateMdmAppSettingBeta `
        -MdmAppId $mdmAppId `
        -IsHotpatchEnabled $true `
        -WhatIf
 
    Adapts the documented mdmAppSetting create request and previews enabling Hotpatch.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [guid] $MdmAppId,

        [Parameter(Mandatory)]
        [bool] $IsHotpatchEnabled
    )

    $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.mdmAppSetting'
        mdmAppId = $MdmAppId.ToString()
        isHotpatchEnabled = $IsHotpatchEnabled
    }
    if ($PSCmdlet.ShouldProcess($MdmAppId, 'Create beta MDM app setting')) {
        Invoke-MgWindowsUpdatesRequest -Method POST `
            -Path 'tenantSettings/mdmAppSettings' `
            -Body $body
    }
}

function Set-MgWindowsUpdateMdmAppSettingBeta {
    <#
    .SYNOPSIS
    Updates an MDM application setting for Windows Autopatch using the beta API.
    .DESCRIPTION
    Updates an MDM application setting for Windows Autopatch 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 IsHotpatchEnabled
    Specifies the is hotpatch enabled.
    .PARAMETER MdmAppId
    Specifies the Microsoft Graph identifier of the mdm app.
    .EXAMPLE
    PS> $mdmAppId = [guid] '6e8fb67d-ac92-5b14-8d6d-3299f92da00c'
    Set-MgWindowsUpdateMdmAppSettingBeta `
        -IsHotpatchEnabled $false `
        -MdmAppId $mdmAppId `
        -WhatIf
 
    Adapts the documented mdmAppSetting update and previews disabling Hotpatch.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [guid] $MdmAppId,

        [Parameter(Mandatory)]
        [bool] $IsHotpatchEnabled
    )

    $body = @{
        '@odata.type' = '#microsoft.graph.windowsUpdates.mdmAppSetting'
        isHotpatchEnabled = $IsHotpatchEnabled
    }
    if ($PSCmdlet.ShouldProcess($MdmAppId, 'Update beta MDM app setting')) {
        Invoke-MgWindowsUpdatesRequest -Method PATCH `
            -Path "tenantSettings/mdmAppSettings/$MdmAppId" `
            -Body $body
    }
}