|
| 1 | + |
| 2 | +# ---------------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# Unless required by applicable law or agreed to in writing, software |
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +# See the License for the specific language governing permissions and |
| 12 | +# limitations under the License. |
| 13 | +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code |
| 14 | +# is regenerated. |
| 15 | +# ---------------------------------------------------------------------------------- |
| 16 | + |
| 17 | +<# |
| 18 | +.Synopsis |
| 19 | +Disables Azure Data Transfer connections. |
| 20 | +.Description |
| 21 | +The Disable-AzDataTransferConnection cmdlet disables Azure Data Transfer connections. |
| 22 | +This prevents data transfer operations on the connections and disables all flows within them. |
| 23 | +.Example |
| 24 | +Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Microsoft.AzureDataTransfer/connections/Connection01" |
| 25 | +.Example |
| 26 | +$connectionIds = @( |
| 27 | + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Microsoft.AzureDataTransfer/connections/Connection01", |
| 28 | + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Microsoft.AzureDataTransfer/connections/Connection02" |
| 29 | +) |
| 30 | +Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId $connectionIds |
| 31 | +
|
| 32 | +.Outputs |
| 33 | +ADT.Models.IPipeline |
| 34 | +.Link |
| 35 | +https://learn.microsoft.com/powershell/module/az.datatransfer/disable-azdatatransferconnection |
| 36 | +#> |
| 37 | +function Disable-AzDataTransferConnection { |
| 38 | +[OutputType([ADT.Models.IPipeline])] |
| 39 | +[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] |
| 40 | +param( |
| 41 | + [Parameter(Mandatory)] |
| 42 | + [ADT.Category('Body')] |
| 43 | + [System.String] |
| 44 | + # The name of the pipeline containing the connections |
| 45 | + ${PipelineName}, |
| 46 | + |
| 47 | + [Parameter(Mandatory)] |
| 48 | + [ADT.Category('Body')] |
| 49 | + [System.String] |
| 50 | + # The name of the resource group |
| 51 | + ${ResourceGroupName}, |
| 52 | + |
| 53 | + [Parameter(Mandatory)] |
| 54 | + [ADT.Category('Body')] |
| 55 | + [System.String[]] |
| 56 | + # One or more connection resource IDs to disable |
| 57 | + ${ConnectionId}, |
| 58 | + |
| 59 | + [Parameter()] |
| 60 | + [ADT.Category('Body')] |
| 61 | + [System.String] |
| 62 | + # The ID of the target subscription |
| 63 | + ${SubscriptionId}, |
| 64 | + |
| 65 | + [Parameter()] |
| 66 | + [ADT.Category('Body')] |
| 67 | + [System.String] |
| 68 | + # Business justification for disabling the connections |
| 69 | + ${Justification}, |
| 70 | + |
| 71 | + [Parameter()] |
| 72 | + [ADT.Category('Body')] |
| 73 | + [System.Management.Automation.PSObject] |
| 74 | + # The credentials, account, tenant, and subscription used for communication with Azure |
| 75 | + ${DefaultProfile}, |
| 76 | + |
| 77 | + [Parameter()] |
| 78 | + [ADT.Category('Body')] |
| 79 | + [System.Management.Automation.SwitchParameter] |
| 80 | + # Run the command as a job |
| 81 | + ${AsJob}, |
| 82 | + |
| 83 | + [Parameter()] |
| 84 | + [ADT.Category('Body')] |
| 85 | + [System.Management.Automation.SwitchParameter] |
| 86 | + # Run the command asynchronously |
| 87 | + ${NoWait} |
| 88 | +) |
| 89 | + |
| 90 | +begin { |
| 91 | + try { |
| 92 | + $outBuffer = $null |
| 93 | + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { |
| 94 | + $PSBoundParameters['OutBuffer'] = 1 |
| 95 | + } |
| 96 | + $parameterSet = $PSCmdlet.ParameterSetName |
| 97 | + |
| 98 | + $testPlayback = $false |
| 99 | + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('ADT.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } |
| 100 | + |
| 101 | + $context = Get-AzContext |
| 102 | + if (-not $context -and -not $testPlayback) { |
| 103 | + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." |
| 104 | + exit |
| 105 | + } |
| 106 | + |
| 107 | + if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { |
| 108 | + [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() |
| 109 | + } |
| 110 | + $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId |
| 111 | + if ($preTelemetryId -eq '') { |
| 112 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString() |
| 113 | + [ADT.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet) |
| 114 | + } else { |
| 115 | + $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets |
| 116 | + if ($internalCalledCmdlets -eq '') { |
| 117 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name |
| 118 | + } else { |
| 119 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name |
| 120 | + } |
| 121 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal' |
| 122 | + } |
| 123 | + |
| 124 | + $mapping = @{ |
| 125 | + __AllParameterSets = 'Az.DataTransfer.custom\Disable-AzDataTransferConnection'; |
| 126 | + } |
| 127 | + $cmdInfo = Get-Command -Name $mapping[$parameterSet] |
| 128 | + [ADT.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) |
| 129 | + if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [ADT.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){ |
| 130 | + [ADT.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) |
| 131 | + [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) |
| 132 | + } |
| 133 | + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) |
| 134 | + if ($wrappedCmd -eq $null) { |
| 135 | + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) |
| 136 | + } |
| 137 | + $scriptCmd = {& $wrappedCmd @PSBoundParameters} |
| 138 | + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) |
| 139 | + $steppablePipeline.Begin($PSCmdlet) |
| 140 | + } catch { |
| 141 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 142 | + throw |
| 143 | + } |
| 144 | +} |
| 145 | + |
| 146 | +process { |
| 147 | + try { |
| 148 | + $steppablePipeline.Process($_) |
| 149 | + } catch { |
| 150 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 151 | + throw |
| 152 | + } |
| 153 | + |
| 154 | + finally { |
| 155 | + $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId |
| 156 | + $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets |
| 157 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 158 | + } |
| 159 | + |
| 160 | +} |
| 161 | +end { |
| 162 | + try { |
| 163 | + $steppablePipeline.End() |
| 164 | + |
| 165 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId |
| 166 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets |
| 167 | + if ($preTelemetryId -eq '') { |
| 168 | + [ADT.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet) |
| 169 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 170 | + } |
| 171 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId |
| 172 | + |
| 173 | + } catch { |
| 174 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 175 | + throw |
| 176 | + } |
| 177 | +} |
| 178 | +} |
0 commit comments