Public/ResourceConnection.ps1
|
function Get-MgWindowsUpdateResourceConnectionBeta { <# .SYNOPSIS Gets Windows updates resource connections using the beta API. .DESCRIPTION Gets Windows updates resource connections 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 OperationalInsightsOnly Specifies the operational insights only. .PARAMETER Query Specifies additional OData query parameters as key-value pairs. .PARAMETER ResourceConnectionId Specifies the Microsoft Graph identifier of the resource connection. .PARAMETER Select Specifies properties to include through OData $select. .PARAMETER Top Specifies the maximum number of items requested from Microsoft Graph. .EXAMPLE PS> Get-MgWindowsUpdateResourceConnectionBeta ` -Select id ` -All Gets Windows updates resource connections using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination. #> [CmdletBinding()] param( [string] $ResourceConnectionId, [switch] $OperationalInsightsOnly, [string] $Filter, [string[]] $Select, [string[]] $Expand, [ValidateRange(1, 999)] [int] $Top, [switch] $All, [hashtable] $Query ) $path = if ($ResourceConnectionId) { "resourceConnections/$ResourceConnectionId" } else { 'resourceConnections' } $odata = Get-MgWindowsUpdatesQuery -BoundParameters $PSBoundParameters $connections = Invoke-MgWindowsUpdatesRequest ` -Method GET ` -Path $path ` -Query $odata ` -All:$All if ($OperationalInsightsOnly -and -not $ResourceConnectionId) { return $connections | Where-Object { (Get-MgWindowsUpdatesProperty -InputObject $_ -Name '@odata.type') -eq '#microsoft.graph.windowsUpdates.operationalInsightsConnection' } } $connections } function New-MgWindowsUpdateOperationalInsightsConnectionBeta { <# .SYNOPSIS Creates a Log Analytics resource connection using the beta API. .DESCRIPTION Creates a Log Analytics resource connection 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 AzureResourceGroupName Specifies the azure resource group name. .PARAMETER AzureSubscriptionId Specifies the Microsoft Graph identifier of the azure subscription. .PARAMETER WorkspaceName Specifies the workspace name. .EXAMPLE PS> $subscriptionId = [guid] '322ec614-e9c2-4cd5-a55c-5711fdecf02e' New-MgWindowsUpdateOperationalInsightsConnectionBeta ` -AzureSubscriptionId $subscriptionId ` -AzureResourceGroupName 'target-resource-group' ` -WorkspaceName 'my-workspace' ` -WhatIf Adapts the documented operationalInsightsConnection example for an existing Log Analytics workspace. #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [guid] $AzureSubscriptionId, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $AzureResourceGroupName, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $WorkspaceName ) $body = @{ '@odata.type' = '#microsoft.graph.windowsUpdates.operationalInsightsConnection' azureSubscriptionId = $AzureSubscriptionId.ToString() azureResourceGroupName = $AzureResourceGroupName workspaceName = $WorkspaceName } if ($PSCmdlet.ShouldProcess($WorkspaceName, 'Create beta Operational Insights connection')) { Invoke-MgWindowsUpdatesRequest -Method POST -Path 'resourceConnections' -Body $body } } function Get-MgWindowsUpdateOperationalInsightsConnectionBeta { <# .SYNOPSIS Gets Operational Insights resource connections using the beta API. .DESCRIPTION Gets Operational Insights resource connections 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 OperationalInsightsConnectionId Specifies the Microsoft Graph identifier of the operational insights connection. .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> Get-MgWindowsUpdateOperationalInsightsConnectionBeta ` -Select id ` -All Gets Operational Insights resource connections using the beta API. The example requests useful identity fields and follows all pages when the endpoint supports pagination. #> [CmdletBinding()] param( [string] $OperationalInsightsConnectionId, [string] $Filter, [string[]] $Select, [string[]] $Expand, [ValidateRange(1, 999)] [int] $Top, [switch] $All, [hashtable] $Query ) $parameters = @{} foreach ($key in $PSBoundParameters.Keys) { $parameters[$key] = $PSBoundParameters[$key] } $parameters.Remove('OperationalInsightsConnectionId') $parameters.OperationalInsightsOnly = $true if ($OperationalInsightsConnectionId) { $parameters.ResourceConnectionId = $OperationalInsightsConnectionId } Get-MgWindowsUpdateResourceConnectionBeta @parameters } function Remove-MgWindowsUpdateOperationalInsightsConnectionBeta { <# .SYNOPSIS Deletes an Operational Insights resource connection using the beta API. .DESCRIPTION Deletes an Operational Insights resource connection 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 OperationalInsightsConnectionId Specifies the Microsoft Graph identifier of the operational insights connection. .EXAMPLE PS> $operationalInsightsConnectionId = '<operational-insights-connection-id>' Remove-MgWindowsUpdateOperationalInsightsConnectionBeta ` -OperationalInsightsConnectionId $operationalInsightsConnectionId ` -WhatIf Deletes an Operational Insights resource connection 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] $OperationalInsightsConnectionId ) if ($PSCmdlet.ShouldProcess( $OperationalInsightsConnectionId, 'Delete beta Operational Insights connection' )) { Remove-MgWindowsUpdateResourceConnectionBeta ` -ResourceConnectionId $OperationalInsightsConnectionId ` -Confirm:$false } } function Remove-MgWindowsUpdateResourceConnectionBeta { <# .SYNOPSIS Deletes a Windows updates resource connection using the beta API. .DESCRIPTION Deletes a Windows updates resource connection 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 ResourceConnectionId Specifies the Microsoft Graph identifier of the resource connection. .EXAMPLE PS> $resourceConnectionId = '<resource-connection-id>' Remove-MgWindowsUpdateResourceConnectionBeta ` -ResourceConnectionId $resourceConnectionId ` -WhatIf Deletes a Windows updates resource connection 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] $ResourceConnectionId ) if ($PSCmdlet.ShouldProcess($ResourceConnectionId, 'Delete beta resource connection')) { Invoke-MgWindowsUpdatesRequest -Method DELETE ` -Path "resourceConnections/$ResourceConnectionId" } } |