|
| 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 | +Retrieves the details of the replicating server status. |
| 20 | +.Description |
| 21 | +The Get-AzMigrateServerMigrationStatus cmdlet retrieves the replication status for the replicating server. |
| 22 | +.Example |
| 23 | +Get-AzMigrateServerMigrationStatus -ResourceGroupName cbtpvtrg -ProjectName migpvt |
| 24 | +.Example |
| 25 | +Get-AzMigrateServerMigrationStatus -ProjectName "migpvt-ecyproj" -ResourceGroupName "cbtprivatestamprg" -MachineName "CVM-Win2019" |
| 26 | +.Example |
| 27 | +Get-AzMigrateServerMigrationStatus -ProjectName "migpvt-ecyproj" -ResourceGroupName "cbtprivatestamprg" -ApplianceName "migpvt" |
| 28 | +
|
| 29 | +.Outputs |
| 30 | +System.Management.Automation.PSObject[] |
| 31 | +.Link |
| 32 | +https://learn.microsoft.com/powershell/module/az.migrate/get-azmigrateservermigrationstatus |
| 33 | +#> |
| 34 | +function Get-AzMigrateServerMigrationStatus { |
| 35 | +[OutputType([System.Management.Automation.PSObject[]])] |
| 36 | +[CmdletBinding(DefaultParameterSetName='ListByName', PositionalBinding=$false)] |
| 37 | +param( |
| 38 | + [Parameter(Mandatory)] |
| 39 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] |
| 40 | + [System.String] |
| 41 | + # [Parameter(ParameterSetName = 'GetByPrioritiseServer', Mandatory)] |
| 42 | + # Specifies the Resource Group of the Azure Migrate Project in the current subscription. |
| 43 | + ${ResourceGroupName}, |
| 44 | + |
| 45 | + [Parameter(Mandatory)] |
| 46 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] |
| 47 | + [System.String] |
| 48 | + # [Parameter(ParameterSetName = 'GetByPrioritiseServer', Mandatory)] |
| 49 | + # Specifies the Azure Migrate project in the current subscription. |
| 50 | + ${ProjectName}, |
| 51 | + |
| 52 | + [Parameter()] |
| 53 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] |
| 54 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] |
| 55 | + [System.String] |
| 56 | + # Azure Subscription ID. |
| 57 | + ${SubscriptionId}, |
| 58 | + |
| 59 | + [Parameter(ParameterSetName='GetByApplianceName', Mandatory)] |
| 60 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] |
| 61 | + [System.String] |
| 62 | + # Specifies the name of the appliance. |
| 63 | + ${ApplianceName}, |
| 64 | + |
| 65 | + [Parameter(ParameterSetName='GetHealthByMachineName', Mandatory)] |
| 66 | + [Parameter(ParameterSetName='GetByMachineName', Mandatory)] |
| 67 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] |
| 68 | + [System.String] |
| 69 | + # [Parameter(ParameterSetName = 'GetByPrioritiseServer', Mandatory)] |
| 70 | + # Specifies the display name of the replicating machine. |
| 71 | + ${MachineName}, |
| 72 | + |
| 73 | + [Parameter(ParameterSetName='GetHealthByMachineName', Mandatory)] |
| 74 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] |
| 75 | + [System.Management.Automation.SwitchParameter] |
| 76 | + # Specifies whether the health issues to show for replicating server. |
| 77 | + ${Health}, |
| 78 | + |
| 79 | + [Parameter(ParameterSetName='ListByName')] |
| 80 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')] |
| 81 | + [System.String] |
| 82 | + # OData filter options. |
| 83 | + ${Filter}, |
| 84 | + |
| 85 | + [Parameter(ParameterSetName='ListByName')] |
| 86 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')] |
| 87 | + [System.String] |
| 88 | + # The pagination token. |
| 89 | + ${SkipToken}, |
| 90 | + |
| 91 | + [Parameter()] |
| 92 | + [Alias('AzureRMContext', 'AzureCredential')] |
| 93 | + [ValidateNotNull()] |
| 94 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] |
| 95 | + [System.Management.Automation.PSObject] |
| 96 | + # The credentials, account, tenant, and subscription used for communication with Azure. |
| 97 | + ${DefaultProfile}, |
| 98 | + |
| 99 | + [Parameter(DontShow)] |
| 100 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] |
| 101 | + [System.Management.Automation.SwitchParameter] |
| 102 | + # Wait for .NET debugger to attach |
| 103 | + ${Break}, |
| 104 | + |
| 105 | + [Parameter(DontShow)] |
| 106 | + [ValidateNotNull()] |
| 107 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] |
| 108 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] |
| 109 | + # SendAsync Pipeline Steps to be appended to the front of the pipeline |
| 110 | + ${HttpPipelineAppend}, |
| 111 | + |
| 112 | + [Parameter(DontShow)] |
| 113 | + [ValidateNotNull()] |
| 114 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] |
| 115 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] |
| 116 | + # SendAsync Pipeline Steps to be prepended to the front of the pipeline |
| 117 | + ${HttpPipelinePrepend}, |
| 118 | + |
| 119 | + [Parameter(DontShow)] |
| 120 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] |
| 121 | + [System.Uri] |
| 122 | + # The URI for the proxy server to use |
| 123 | + ${Proxy}, |
| 124 | + |
| 125 | + [Parameter(DontShow)] |
| 126 | + [ValidateNotNull()] |
| 127 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] |
| 128 | + [System.Management.Automation.PSCredential] |
| 129 | + # Credentials for a proxy server to use for the remote call |
| 130 | + ${ProxyCredential}, |
| 131 | + |
| 132 | + [Parameter(DontShow)] |
| 133 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] |
| 134 | + [System.Management.Automation.SwitchParameter] |
| 135 | + # Use the default credentials for the proxy |
| 136 | + ${ProxyUseDefaultCredentials} |
| 137 | +) |
| 138 | + |
| 139 | +begin { |
| 140 | + try { |
| 141 | + $outBuffer = $null |
| 142 | + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { |
| 143 | + $PSBoundParameters['OutBuffer'] = 1 |
| 144 | + } |
| 145 | + $parameterSet = $PSCmdlet.ParameterSetName |
| 146 | + |
| 147 | + if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { |
| 148 | + [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() |
| 149 | + } |
| 150 | + $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId |
| 151 | + if ($preTelemetryId -eq '') { |
| 152 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString() |
| 153 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet) |
| 154 | + } else { |
| 155 | + $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets |
| 156 | + if ($internalCalledCmdlets -eq '') { |
| 157 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name |
| 158 | + } else { |
| 159 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name |
| 160 | + } |
| 161 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal' |
| 162 | + } |
| 163 | + |
| 164 | + $mapping = @{ |
| 165 | + ListByName = 'Az.Migrate.custom\Get-AzMigrateServerMigrationStatus'; |
| 166 | + GetByApplianceName = 'Az.Migrate.custom\Get-AzMigrateServerMigrationStatus'; |
| 167 | + GetHealthByMachineName = 'Az.Migrate.custom\Get-AzMigrateServerMigrationStatus'; |
| 168 | + GetByMachineName = 'Az.Migrate.custom\Get-AzMigrateServerMigrationStatus'; |
| 169 | + } |
| 170 | + if (('ListByName', 'GetByApplianceName', 'GetHealthByMachineName', 'GetByMachineName') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { |
| 171 | + $testPlayback = $false |
| 172 | + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } |
| 173 | + if ($testPlayback) { |
| 174 | + $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') |
| 175 | + } else { |
| 176 | + $PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id |
| 177 | + } |
| 178 | + } |
| 179 | + $cmdInfo = Get-Command -Name $mapping[$parameterSet] |
| 180 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) |
| 181 | + if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){ |
| 182 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) |
| 183 | + [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) |
| 184 | + } |
| 185 | + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) |
| 186 | + $scriptCmd = {& $wrappedCmd @PSBoundParameters} |
| 187 | + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) |
| 188 | + $steppablePipeline.Begin($PSCmdlet) |
| 189 | + } catch { |
| 190 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 191 | + throw |
| 192 | + } |
| 193 | +} |
| 194 | + |
| 195 | +process { |
| 196 | + try { |
| 197 | + $steppablePipeline.Process($_) |
| 198 | + } catch { |
| 199 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 200 | + throw |
| 201 | + } |
| 202 | + |
| 203 | + finally { |
| 204 | + $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId |
| 205 | + $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets |
| 206 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 207 | + } |
| 208 | + |
| 209 | +} |
| 210 | +end { |
| 211 | + try { |
| 212 | + $steppablePipeline.End() |
| 213 | + |
| 214 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId |
| 215 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets |
| 216 | + if ($preTelemetryId -eq '') { |
| 217 | + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet) |
| 218 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 219 | + } |
| 220 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId |
| 221 | + |
| 222 | + } catch { |
| 223 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 224 | + throw |
| 225 | + } |
| 226 | +} |
| 227 | +} |
0 commit comments