Public/Deployment.ps1
|
function Get-MgWindowsUpdateDeploymentBeta { <# .SYNOPSIS Gets one or more Windows update deployments from the beta API. .DESCRIPTION Gets one or more Windows update deployments 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 DeploymentId Specifies the Microsoft Graph identifier of the deployment. .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 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-MgWindowsUpdateDeploymentBeta ` -Select id ` -All Gets one or more Windows update deployments from the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination. #> [CmdletBinding()] param( [string] $DeploymentId, [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 ($DeploymentId) { "deployments/$DeploymentId" } else { 'deployments' } $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata -All:$All } function New-MgWindowsUpdateDeploymentBeta { <# .SYNOPSIS Creates a Windows update deployment using the beta API. .DESCRIPTION Creates a Windows update deployment 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.deployment' content = @{ '@odata.type' = '#microsoft.graph.windowsUpdates.catalogContent' catalogEntry = @{ '@odata.type' = ( '#microsoft.graph.windowsUpdates.featureUpdateCatalogEntry' ) id = 'f341705b-0b15-4ce3-aaf2-6a1681d78606' } } settings = @{ '@odata.type' = '#microsoft.graph.windowsUpdates.deploymentSettings' schedule = @{ gradualRollout = @{ '@odata.type' = ( '#microsoft.graph.windowsUpdates.rateDrivenRolloutSettings' ) durationBetweenOffers = 'P7D' devicesPerOffer = 100 } } } } New-MgWindowsUpdateDeploymentBeta ` -Body $body ` -WhatIf Adapts the documented Microsoft Graph deployment example for a feature update. Remove -WhatIf after replacing the catalog entry and reviewing the rollout settings. #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [ValidateNotNull()] [hashtable] $Body ) if ($PSCmdlet.ShouldProcess('Windows updates deployments', 'Create beta deployment')) { Invoke-MgWindowsUpdatesRequest -Method POST -Path 'deployments' -Body $Body } } function Set-MgWindowsUpdateDeploymentBeta { <# .SYNOPSIS Updates a Windows update deployment using the beta API. .DESCRIPTION Updates a Windows update deployment 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 DeploymentId Specifies the Microsoft Graph identifier of the deployment. .EXAMPLE PS> $body = @{ settings = @{ schedule = @{ gradualRollout = @{ '@odata.type' = ( '#microsoft.graph.windowsUpdates.rateDrivenRolloutSettings' ) durationBetweenOffers = 'P1D' devicesPerOffer = 50 } } } } $deploymentId = 'd39ad1ce-0123-4567-89ab-cdef01234567' Set-MgWindowsUpdateDeploymentBeta ` -Body $body ` -DeploymentId $deploymentId ` -WhatIf Previews changing the documented rate-driven rollout settings for a deployment. #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string] $DeploymentId, [Parameter(Mandatory)] [ValidateNotNull()] [hashtable] $Body ) if ($PSCmdlet.ShouldProcess($DeploymentId, 'Update beta deployment')) { Invoke-MgWindowsUpdatesRequest -Method PATCH -Path "deployments/$DeploymentId" -Body $Body } } function Remove-MgWindowsUpdateDeploymentBeta { <# .SYNOPSIS Deletes a Windows update deployment using the beta API. .DESCRIPTION Deletes a Windows update deployment 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 DeploymentId Specifies the Microsoft Graph identifier of the deployment. .EXAMPLE PS> $deploymentId = '<deployment-id>' Remove-MgWindowsUpdateDeploymentBeta ` -DeploymentId $deploymentId ` -WhatIf Deletes a Windows update deployment 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] $DeploymentId ) if ($PSCmdlet.ShouldProcess($DeploymentId, 'Delete beta deployment')) { Invoke-MgWindowsUpdatesRequest -Method DELETE -Path "deployments/$DeploymentId" } } function Get-MgWindowsUpdateDeploymentAudienceBeta { <# .SYNOPSIS Gets one or more deployment audiences from the beta API. .DESCRIPTION Gets one or more deployment audiences 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 DeploymentAudienceId Specifies the Microsoft Graph identifier of the deployment audience. .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 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-MgWindowsUpdateDeploymentAudienceBeta ` -Select id ` -All Gets one or more deployment audiences from the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination. #> [CmdletBinding()] param( [string] $DeploymentAudienceId, [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 ($DeploymentAudienceId) { "deploymentAudiences/$DeploymentAudienceId" } else { 'deploymentAudiences' } $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters Invoke-MgWindowsUpdatesRequest -Method GET -Path $path -Query $odata -All:$All } function New-MgWindowsUpdateDeploymentAudienceBeta { <# .SYNOPSIS Creates a deployment audience using the beta API. .DESCRIPTION Creates a deployment audience 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 = @{} New-MgWindowsUpdateDeploymentAudienceBeta ` -Body $body ` -WhatIf Uses the documented empty request body to preview creating a deployment audience. #> [CmdletBinding(SupportsShouldProcess)] param( [hashtable] $Body = @{} ) if ($PSCmdlet.ShouldProcess('Windows updates deployment audiences', 'Create beta audience')) { Invoke-MgWindowsUpdatesRequest -Method POST -Path 'deploymentAudiences' -Body $Body } } function Remove-MgWindowsUpdateDeploymentAudienceBeta { <# .SYNOPSIS Deletes a deployment audience using the beta API. .DESCRIPTION Deletes a deployment audience 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 DeploymentAudienceId Specifies the Microsoft Graph identifier of the deployment audience. .EXAMPLE PS> $deploymentAudienceId = '<deployment-audience-id>' Remove-MgWindowsUpdateDeploymentAudienceBeta ` -DeploymentAudienceId $deploymentAudienceId ` -WhatIf Deletes a deployment audience 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] $DeploymentAudienceId ) if ($PSCmdlet.ShouldProcess($DeploymentAudienceId, 'Delete beta deployment audience')) { Invoke-MgWindowsUpdatesRequest -Method DELETE ` -Path "deploymentAudiences/$DeploymentAudienceId" } } function Get-MgWindowsUpdateDeploymentAudienceMemberBeta { <# .SYNOPSIS Gets deployment audience members or exclusions from the beta API. .DESCRIPTION Gets deployment audience members or exclusions 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 DeploymentAudienceId Specifies the Microsoft Graph identifier of the deployment audience. .PARAMETER Exclusion Returns or updates exclusions instead of members. .PARAMETER Query Specifies additional OData query parameters as key-value pairs. .EXAMPLE PS> $deploymentAudienceId = '<deployment-audience-id>' Get-MgWindowsUpdateDeploymentAudienceMemberBeta ` -DeploymentAudienceId $deploymentAudienceId ` -All Gets deployment audience members or exclusions from the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination. #> [CmdletBinding()] param( [Parameter(Mandatory)] [string] $DeploymentAudienceId, [switch] $Exclusion, [switch] $All, [hashtable] $Query ) $relationship = if ($Exclusion) { 'exclusions' } else { 'members' } $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters Invoke-MgWindowsUpdatesRequest -Method GET ` -Path "deploymentAudiences/$DeploymentAudienceId/$relationship" ` -Query $odata ` -All:$All } function Update-MgWindowsUpdateDeploymentAudienceBeta { <# .SYNOPSIS Updates deployment audience members and exclusions using typed asset objects. .DESCRIPTION Updates deployment audience members and exclusions using typed asset objects. 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 DeploymentAudienceId Specifies the Microsoft Graph identifier of the deployment audience. .EXAMPLE PS> $body = @{ addMembers = @( @{ '@odata.type' = '#microsoft.graph.windowsUpdates.azureADDevice' id = '01234567-89ab-cdef-0123-456789abcdef' } @{ '@odata.type' = '#microsoft.graph.windowsUpdates.azureADDevice' id = '01234567-89ab-cdef-0123-456789abcde0' } ) } $deploymentAudienceId = 'd39ad1ce-0123-4567-89ab-cdef01234567' Update-MgWindowsUpdateDeploymentAudienceBeta ` -Body $body ` -DeploymentAudienceId $deploymentAudienceId ` -WhatIf Adapts the documented Graph request that adds Microsoft Entra devices to a deployment audience. Remove -WhatIf after validating the audience and device IDs. #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string] $DeploymentAudienceId, [Parameter(Mandatory)] [ValidateNotNull()] [hashtable] $Body ) if ($PSCmdlet.ShouldProcess($DeploymentAudienceId, 'Update beta deployment audience')) { Invoke-MgWindowsUpdatesRequest -Method POST ` -Path "deploymentAudiences/$DeploymentAudienceId/updateAudience" ` -Body $Body } } function Update-MgWindowsUpdateDeploymentAudienceByIdBeta { <# .SYNOPSIS Updates a deployment audience using asset IDs through the beta API. .DESCRIPTION Updates a deployment audience using asset IDs through 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 AddExclusion Specifies asset identifiers to add as audience exclusions. .PARAMETER AddMember Specifies asset identifiers to add as audience members. .PARAMETER DeploymentId Specifies the Microsoft Graph identifier of the deployment. .PARAMETER MemberEntityType Specifies the Microsoft Graph asset type used by member identifiers. .PARAMETER RemoveExclusion Specifies asset identifiers to remove from audience exclusions. .PARAMETER RemoveMember Specifies asset identifiers to remove from audience members. .EXAMPLE PS> $deploymentId = 'd39ad1ce-0123-4567-89ab-cdef01234567' $deviceIds = @( '01234567-89ab-cdef-0123-456789abcdef' '01234567-89ab-cdef-0123-456789abcde0' ) Update-MgWindowsUpdateDeploymentAudienceByIdBeta ` -DeploymentId $deploymentId ` -MemberEntityType '#microsoft.graph.windowsUpdates.azureADDevice' ` -AddMember $deviceIds ` -WhatIf Uses the documented updateAudienceById payload shape to preview adding devices to the deployment audience. Remove -WhatIf after validating each identifier. #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string] $DeploymentId, [Parameter(Mandatory)] [ValidateSet( '#microsoft.graph.windowsUpdates.azureADDevice', '#microsoft.graph.windowsUpdates.updatableAssetGroup' )] [string] $MemberEntityType, [string[]] $AddMember, [string[]] $RemoveMember, [string[]] $AddExclusion, [string[]] $RemoveExclusion ) $body = @{ memberEntityType = $MemberEntityType } $parameterMap = @{ AddMember = 'addMembers' RemoveMember = 'removeMembers' AddExclusion = 'addExclusions' RemoveExclusion = 'removeExclusions' } foreach ($parameterName in $parameterMap.Keys) { if ($PSBoundParameters.ContainsKey($parameterName) -and @($PSBoundParameters[$parameterName]).Count -gt 0) { $body[$parameterMap[$parameterName]] = @($PSBoundParameters[$parameterName]) } } if ($body.Count -eq 1) { throw 'Specify at least one member or exclusion list to update.' } if ($PSCmdlet.ShouldProcess($DeploymentId, 'Update beta deployment audience by ID')) { Invoke-MgWindowsUpdatesRequest -Method POST ` -Path "deployments/$DeploymentId/audience/updateAudienceById" ` -Body $body } } |