diff --git a/src/Migrate/custom/Get-AzMigrateJob.ps1 b/src/Migrate/custom/Get-AzMigrateJob.ps1 deleted file mode 100644 index 605d37e91fc1..000000000000 --- a/src/Migrate/custom/Get-AzMigrateJob.ps1 +++ /dev/null @@ -1,192 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Retrieves the status of an Azure Migrate job. -.Description -The Get-AzMigrateJob cmdlet retrives the status of an Azure Migrate job. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/get-azmigratejob -#> -function Get-AzMigrateJob { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ListByName', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='GetById', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the job id for which the details needs to be retrieved. - ${JobID}, - - [Parameter(ParameterSetName='GetByName', Mandatory)] - [Parameter(ParameterSetName='ListByName', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # The name of the resource group where the recovery services vault is present. - ${ResourceGroupName}, - - [Parameter(ParameterSetName='GetByName', Mandatory)] - [Parameter(ParameterSetName='ListByName', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # The name of the migrate project. - ${ProjectName}, - - [Parameter(ParameterSetName='GetByName', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Job identifier - ${JobName}, - - [Parameter(ParameterSetName='GetByInputObject', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob] - # Specifies the job object of the replicating server. - ${InputObject}, - - [Parameter(ParameterSetName='ListById', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Resource Group of the Azure Migrate Project in the current subscription. - ${ResourceGroupID}, - - [Parameter(ParameterSetName='ListById', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Azure Migrate Project in which servers are replicating. - ${ProjectID}, - - [Parameter(ParameterSetName='ListByName')] - [Parameter(ParameterSetName='ListById')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')] - [System.String] - # OData filter options. - ${Filter}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - $parameterSet = $PSCmdlet.ParameterSetName - $null = $PSBoundParameters.Remove('JobID') - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ProjectName') - $null = $PSBoundParameters.Remove('JobName') - $null = $PSBoundParameters.Remove('InputObject') - $null = $PSBoundParameters.Remove('InputServerObject') - $null = $PSBoundParameters.Remove('ResourceGroupID') - $null = $PSBoundParameters.Remove('ProjectID') - $HasFilter = $PSBoundParameters.ContainsKey('Filter') - $null = $PSBoundParameters.Remove('Filter') - - - if(($parameterSet -match 'Name') -or ($parameterSet -eq 'ListById')){ - if($parameterSet -eq 'ListById'){ - $ProjectName = $ProjectID.Split("/")[8] - $ResourceGroupName = $ResourceGroupID.Split("/")[4] - } - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("Name", "Servers-Migration-ServerMigration") - $null = $PSBoundParameters.Add("MigrateProjectName", $ProjectName) - - $solution = Az.Migrate\Get-AzMigrateSolution @PSBoundParameters - if($solution -and ($solution.Count -ge 1)){ - $ResourceName = $solution.DetailExtendedDetail.AdditionalProperties.vaultId.Split("/")[8] - }else{ - throw "Solution not found." - } - $null = $PSBoundParameters.Remove("Name") - $null = $PSBoundParameters.Remove("MigrateProjectName") - $null = $PSBoundParameters.Remove("ResourceGroupName") - }else{ - if($parameterSet -eq 'GetByInputObject'){ - $JobID = $InputObject.Id - } - $JobIdArray = $JobID.split('/') - $JobName = $JobIdArray[10] - $ResourceName = $JobIdArray[8] - $ResourceGroupName = $JobIdArray[4] - } - - if($parameterSet -match 'Get'){ - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $ResourceName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - }else{ - $null = $PSBoundParameters.Add('ResourceName', $ResourceName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - if($HasFilter){$null = $PSBoundParameters.Add('Filter', $Filter)} - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - } - - - } -} \ No newline at end of file diff --git a/src/Migrate/custom/Get-AzMigrateServerReplication.ps1 b/src/Migrate/custom/Get-AzMigrateServerReplication.ps1 deleted file mode 100644 index 478b32d30553..000000000000 --- a/src/Migrate/custom/Get-AzMigrateServerReplication.ps1 +++ /dev/null @@ -1,260 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Retrieves the details of the replicating server. -.Description -The Get-AzMigrateServerReplication cmdlet retrieves the object for the replicating server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/get-azmigrateserverreplication -#> -function Get-AzMigrateServerReplication { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem])] - [CmdletBinding(DefaultParameterSetName='ListByName', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='GetBySRSID', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replicating server. - ${TargetObjectID}, - - [Parameter(ParameterSetName='ListByName', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Resource Group of the Azure Migrate Project in the current subscription. - ${ResourceGroupName}, - - [Parameter(ParameterSetName='ListByName', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Azure Migrate project in the current subscription. - ${ProjectName}, - - [Parameter(ParameterSetName='GetBySDSID', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the machine ID of the discovered server. - ${DiscoveredMachineId}, - - [Parameter(ParameterSetName='GetByInputObject', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem] - # Specifies the machine object of the replicating server. - ${InputObject}, - - [Parameter(ParameterSetName='ListById', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Resource Group of the Azure Migrate Project in the current subscription. - ${ResourceGroupID}, - - [Parameter(ParameterSetName='ListById', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Azure Migrate Project in which servers are replicating. - ${ProjectID}, - - [Parameter(ParameterSetName='ListByName')] - [Parameter(ParameterSetName='ListById')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')] - [System.String] - # OData filter options. - ${Filter}, - - [Parameter(ParameterSetName='ListByName')] - [Parameter(ParameterSetName='ListById')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')] - [System.String] - # The pagination token. - ${SkipToken}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - $parameterSet = $PSCmdlet.ParameterSetName - $null = $PSBoundParameters.Remove('TargetObjectID') - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ProjectName') - $null = $PSBoundParameters.Remove('DiscoveredMachineId') - $null = $PSBoundParameters.Remove('InputObject') - $null = $PSBoundParameters.Remove('ResourceGroupID') - $null = $PSBoundParameters.Remove('ProjectID') - $HasFilter = $PSBoundParameters.ContainsKey('Filter') - $HasSkipToken = $PSBoundParameters.ContainsKey('SkipToken') - $null = $PSBoundParameters.Remove('Filter') - $null = $PSBoundParameters.Remove('SkipToken') - - if ($parameterSet -eq "GetBySDSID"){ - $MachineIdArray = $DiscoveredMachineId.Split("/") - $SiteType = $MachineIdArray[7] - $SiteName = $MachineIdArray[8] - $ResourceGroupName = $MachineIdArray[4] - $MachineName = $MachineIdArray[10] - - if ($SiteType -ne "VMwareSites"){ - throw "Provider not supported." - } - - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - $null = $PSBoundParameters.Add('SiteName', $SiteName) - $siteObject = Az.Migrate\Get-AzMigrateSite @PSBoundParameters - $ProjectName = $siteObject.DiscoverySolutionId.Split("/")[8] - - $null = $PSBoundParameters.Remove('SiteName') - - $null = $PSBoundParameters.Add("Name", "Servers-Migration-ServerMigration") - $null = $PSBoundParameters.Add("MigrateProjectName", $ProjectName) - - $solution = Az.Migrate\Get-AzMigrateSolution @PSBoundParameters - if($solution -and ($solution.Count -ge 1)){ - $VaultName = $solution.DetailExtendedDetail.AdditionalProperties.vaultId.Split("/")[8] - - $null = $PSBoundParameters.Remove("Name") - $null = $PSBoundParameters.Remove("MigrateProjectName") - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $allFabrics = Az.Migrate\Get-AzMigrateReplicationFabric @PSBoundParameters - $FabricName = "" - if($allFabrics -and ($allFabrics.length -gt 0)){ - foreach ($fabric in $allFabrics) { - if(($fabric.Property.CustomDetail.InstanceType -ceq "VMwareV2") -and ($fabric.Property.CustomDetail.VmwareSiteId.Split("/")[8] -ceq $SiteName)){ - $FabricName = $fabric.Name - break - } - } - } - if($FabricName -eq ""){ - throw "Fabric not found for given resource group" - } - - $null = $PSBoundParameters.Add('FabricName', $FabricName) - $peContainers = Az.Migrate\Get-AzMigrateReplicationProtectionContainer @PSBoundParameters - $ProtectionContainerName = "" - if($peContainers -and ($peContainers.length -gt 0)){ - $ProtectionContainerName = $peContainers[0].Name - } - - if($ProtectionContainerName -eq ""){ - throw "Container not found for given resource group" - } - - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - return Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - }else{ - throw "Solution not found." - } - } - - if($parameterSet -match 'List'){ - if($parameterSet -eq 'ListById'){ - $ProjectName = $ProjectID.Split("/")[8] - $ResourceGroupName = $ResourceGroupID.Split("/")[4] - } - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("Name", "Servers-Migration-ServerMigration") - $null = $PSBoundParameters.Add("MigrateProjectName", $ProjectName) - - $solution = Az.Migrate\Get-AzMigrateSolution @PSBoundParameters - if($solution -and ($solution.Count -ge 1)){ - $VaultName = $solution.DetailExtendedDetail.AdditionalProperties.vaultId.Split("/")[8] - }else{ - throw "Solution not found." - } - - $null = $PSBoundParameters.Remove("Name") - $null = $PSBoundParameters.Remove("MigrateProjectName") - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - - if($HasFilter){$null = $PSBoundParameters.Add("Filter", $Filter)} - if($HasSkipToken){$null = $PSBoundParameters.Add("SkipToken", $SkipToken)} - - return Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - } - - if (($parameterSet -eq "GetByInputObject") -or ($parameterSet -eq "GetBySRSID")){ - if($parameterSet -eq 'GetByInputObject'){ - $TargetObjectID = $InputObject.Id - } - $MachineIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $MachineIdArray[4] - $VaultName = $MachineIdArray[8] - $FabricName = $MachineIdArray[10] - $ProtectionContainerName = $MachineIdArray[12] - $MachineName = $MachineIdArray[14] - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("ResourceName", $VaultName) - $null = $PSBoundParameters.Add("FabricName", $FabricName) - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - return Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - } - } -} \ No newline at end of file diff --git a/src/Migrate/custom/New-AzMigrateDiskMapping.ps1 b/src/Migrate/custom/New-AzMigrateDiskMapping.ps1 deleted file mode 100644 index 934776366b5b..000000000000 --- a/src/Migrate/custom/New-AzMigrateDiskMapping.ps1 +++ /dev/null @@ -1,65 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Creates a new disk mapping -.Description -The New-AzMigrateDiskMapping cmdlet creates a mapping of the source disk attached to the server to be migrated -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/new-azmigratediskmapping -#> -function New-AzMigrateDiskMapping { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IVMwareCbtDiskInput])] - [CmdletBinding(DefaultParameterSetName='VMwareCbt', PositionalBinding=$false)] - param( - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the disk ID of the disk attached to the discovered server to be migrated. - ${DiskID}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies whether the disk contains the Operating System for the source server to be migrated. - ${IsOSDisk}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Support.DiskAccountType] - # Specifies the type of disks to be used for the Azure VM. - ${DiskType}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the disk encyption set to be used. - ${DiskEncryptionSetID} - ) - - process { - - $DiskObject = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtDiskInput]::new() - $DiskObject.DiskId = $DiskID - $DiskObject.DiskType = $DiskType - $DiskObject.IsOSDisk = $IsOSDisk - if($PSBoundParameters.ContainsKey('DiskEncryptionSetID')){ - $DiskObject.DiskEncryptionSetId = $DiskEncryptionSetID - } - return $DiskObject - } - -} \ No newline at end of file diff --git a/src/Migrate/custom/New-AzMigrateNicMapping.ps1 b/src/Migrate/custom/New-AzMigrateNicMapping.ps1 deleted file mode 100644 index e7dc59fe1c74..000000000000 --- a/src/Migrate/custom/New-AzMigrateNicMapping.ps1 +++ /dev/null @@ -1,78 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Creates an object to update NIC properties of a replicating server. -.Description -The New-AzMigrateNicMapping cmdlet creates a mapping of the source NIC attached to the server to be migrated. This object is provided as an input to the Set-AzMigrateServerReplication cmdlet to update the NIC and its properties for a replicating server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/new-azmigratenicmapping -#> -function New-AzMigrateNicMapping { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IVMwareCbtNicInput])] - [CmdletBinding(DefaultParameterSetName='VMwareCbt', PositionalBinding=$false)] - param( - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the ID of the NIC to be updated. - ${NicID}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies whether the NIC to be updated will be the primary, secondary or not migrated. - ${TargetNicSelectionType}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Subnet name for the NIC in the destination Virtual Network to which the server needs to be migrated. - ${TargetNicSubnet}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the IP within the destination subnet to be used for the NIC. - ${TargetNicIP} - ) - - process { - $NicObject = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtNicInput]::new() - $NicObject.NicId = $NicID - if($PSBoundParameters.ContainsKey('TargetNicSelectionType')){ - if($TargetNicSelectionType -eq 'primary'){ - $NicObject.IsPrimaryNic = "true" - $NicObject.IsSelectedForMigration = "true" - }elseif($TargetNicSelectionType -eq 'secondary'){ - $NicObject.IsPrimaryNic = "false" - $NicObject.IsSelectedForMigration = "true" - }elseif($TargetNicSelectionType -eq 'donotcreate'){ - $NicObject.IsPrimaryNic = "false" - $NicObject.IsSelectedForMigration = "false" - } - } - if($PSBoundParameters.ContainsKey('TargetNicSubnet')){ - $NicObject.TargetSubnetName = $TargetNicSubnet - } - - if($PSBoundParameters.ContainsKey('TargetNicIP')){ - $NicObject.TargetStaticIPAddress = $TargetNicIP - } - return $NicObject - } - -} \ No newline at end of file diff --git a/src/Migrate/custom/New-AzMigrateServerReplication.ps1 b/src/Migrate/custom/New-AzMigrateServerReplication.ps1 deleted file mode 100644 index 7b21626040f1..000000000000 --- a/src/Migrate/custom/New-AzMigrateServerReplication.ps1 +++ /dev/null @@ -1,455 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Starts replication for the specified server. -.Description -The New-AzMigrateServerReplication cmdlet starts the replication for a particular discovered server in the Azure Migrate project. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/new-azmigrateserverreplication -#> -function New-AzMigrateServerReplication { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ByIdDefaultUser', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='ByIdDefaultUser', Mandatory)] - [Parameter(ParameterSetName='ByIdPowerUser', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the machine ID of the discovered server to be migrated. - ${MachineId}, - - [Parameter(ParameterSetName='ByInputObjectDefaultUser', Mandatory)] - [Parameter(ParameterSetName='ByInputObjectPowerUser', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api202001.IVMwareMachine] - # Specifies the discovered server to be migrated. The server object can be retrieved using the Get-AzMigrateServer cmdlet. - ${InputObject}, - - [Parameter(ParameterSetName='ByIdPowerUser', Mandatory)] - [Parameter(ParameterSetName='ByInputObjectPowerUser', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IVMwareCbtDiskInput[]] - # Specifies the disks on the source server to be included for replication. - ${DiskToInclude}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Support.LicenseType] - # Specifies if Azure Hybrid benefit is applicable for the source server to be migrated. - ${LicenseType}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Resource Group id within the destination Azure subscription to which the server needs to be migrated. - ${TargetResourceGroupId}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Virtual Network id within the destination Azure subscription to which the server needs to be migrated. - ${TargetNetworkId}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Subnet name within the destination Virtual Netowk to which the server needs to be migrated. - ${TargetSubnetName}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Mapping. - ${ReplicationContainerMapping}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Account id. - ${VMWarerunasaccountID}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the name of the Azure VM to be created. - ${TargetVMName}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the SKU of the Azure VM to be created. - ${TargetVMSize}, - - [Parameter(ParameterSetName='ByIdDefaultUser')] - [Parameter(ParameterSetName='ByInputObjectDefaultUser')] - [Parameter(ParameterSetName='ByIdPowerUser')] - [Parameter(ParameterSetName='ByInputObjectPowerUser')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies if replication be auto-repaired in case change tracking is lost for the source server under replication. - ${PerformAutoResync}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Availability Set to be used for VM creationSpecifies the Availability Set to be used for VM creation. - ${TargetAvailabilitySet}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Availability Zone to be used for VM creation. - ${TargetAvailabilityZone}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the storage account to be used for boot diagnostics. - ${TargetBootDiagnosticsStorageAccount}, - - [Parameter(ParameterSetName='ByIdDefaultUser', Mandatory)] - [Parameter(ParameterSetName='ByInputObjectDefaultUser', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Support.DiskAccountType] - # Specifies the type of disks to be used for the Azure VM. - ${DiskType}, - - [Parameter(ParameterSetName='ByIdDefaultUser', Mandatory)] - [Parameter(ParameterSetName='ByInputObjectDefaultUser', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Operating System disk for the source server to be migrated. - ${OSDiskID}, - - [Parameter(ParameterSetName='ByIdDefaultUser')] - [Parameter(ParameterSetName='ByInputObjectDefaultUser')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the disk encyption set to be used. - ${DiskEncryptionSetID}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - $parameterSet = $PSCmdlet.ParameterSetName - $HasRunAsAccountId = $PSBoundParameters.ContainsKey('VMWarerunasaccountID') - $HasTargetAVSet = $PSBoundParameters.ContainsKey('TargetAvailabilitySet') - $HasTargetAVZone = $PSBoundParameters.ContainsKey('TargetAvailabilityZone') - $HasTargetBDStorage = $PSBoundParameters.ContainsKey('TargetBootDiagnosticsStorageAccount') - $HasResync = $PSBoundParameters.ContainsKey('PerformAutoResync') - $HasDiskEncryptionSetID = $PSBoundParameters.ContainsKey('DiskEncryptionSetID') - $HasTargetVMSize = $PSBoundParameters.ContainsKey('TargetVMSize') - - $null = $PSBoundParameters.Remove('ReplicationContainerMapping') - $null = $PSBoundParameters.Remove('VMWarerunasaccountID') - $null = $PSBoundParameters.Remove('TargetAvailabilitySet') - $null = $PSBoundParameters.Remove('TargetAvailabilityZone') - $null = $PSBoundParameters.Remove('TargetBootDiagnosticsStorageAccount') - $null = $PSBoundParameters.Remove('MachineId') - $null = $PSBoundParameters.Remove('DiskToInclude') - $null = $PSBoundParameters.Remove('TargetResourceGroupId') - $null = $PSBoundParameters.Remove('TargetNetworkId') - $null = $PSBoundParameters.Remove('TargetSubnetName') - $null = $PSBoundParameters.Remove('TargetVMName') - $null = $PSBoundParameters.Remove('TargetVMSize') - $null = $PSBoundParameters.Remove('PerformAutoResync') - $null = $PSBoundParameters.Remove('DiskType') - $null = $PSBoundParameters.Remove('OSDiskID') - $null = $PSBoundParameters.Remove('LicenseType') - $null = $PSBoundParameters.Remove('DiskEncryptionSetID') - - $null = $PSBoundParameters.Remove('MachineId') - $null = $PSBoundParameters.Remove('InputObject') - - if(($parameterSet -match 'Id') -or ($parameterSet -match 'InputObject')){ - if(($parameterSet -match 'InputObject')){ - $MachineId = $InputObject.Id - } - $MachineIdArray = $MachineId.Split("/") - $SiteType = $MachineIdArray[7] - $SiteName = $MachineIdArray[8] - $ResourceGroupName = $MachineIdArray[4] - $MachineName = $MachineIdArray[10] - - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - $null = $PSBoundParameters.Add('SiteName', $SiteName) - $siteObject = Az.Migrate\Get-AzMigrateSite @PSBoundParameters - if($siteObject -and ($siteObject.Count -ge 1)){ - $ProjectName = $siteObject.DiscoverySolutionId.Split("/")[8] - }else{ - throw "Site not found" - } - - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('SiteName') - - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("Name", "Servers-Migration-ServerMigration") - $null = $PSBoundParameters.Add("MigrateProjectName", $ProjectName) - - $solution = Az.Migrate\Get-AzMigrateSolution @PSBoundParameters - $VaultName = $solution.DetailExtendedDetail.AdditionalProperties.vaultId.Split("/")[8] - - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove("Name") - $null = $PSBoundParameters.Remove("MigrateProjectName") - } - if ($SiteType -ne "VMwareSites"){ - throw "Provider not supported" - } - - if(!$HasRunAsAccountId){ - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - $null = $PSBoundParameters.Add('SiteName', $SiteName) - $runAsAccounts = Az.Migrate\Get-AzMigrateRunAsAccount @PSBoundParameters - $VMWarerunasaccountID = "" - foreach($account in $runAsAccounts){ - $runasAccountSiteName = $account.Id.Split("/")[8] - if( $runasAccountSiteName -ceq $SiteName){ - $VMWarerunasaccountID = $account.Id - break - } - } - if($VMWarerunasaccountID -eq ""){ - throw "Run As Account missing" - } - - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('SiteName') - } - - $policyName = "migrate" + $SiteName + "policy" - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('PolicyName', $policyName) - $policyObj = Az.Migrate\Get-AzMigrateReplicationPolicy @PSBoundParameters -ErrorVariable notPresent -ErrorAction SilentlyContinue - if($policyObj -and ($policyObj.Count -ge 1)){ - $PolicyId = $policyObj.Id - }else{ - throw "The replication infrastructure is not initialized. Run the initialize-azmigratereplicationinfrastructure script again." - } - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ResourceName') - $null = $PSBoundParameters.Remove('PolicyName') - - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $allFabrics = Az.Migrate\Get-AzMigrateReplicationFabric @PSBoundParameters - $FabricName = "" - if($allFabrics -and ($allFabrics.length -gt 0)){ - foreach ($fabric in $allFabrics) { - if(($fabric.Property.CustomDetail.InstanceType -ceq "VMwareV2") -and ($fabric.Property.CustomDetail.VmwareSiteId.Split("/")[8] -ceq $SiteName)){ - $FabricName = $fabric.Name - break - } - } - } - if($FabricName -eq ""){ - throw "Fabric not found for given resource group." - } - - $null = $PSBoundParameters.Add('FabricName', $FabricName) - $peContainers = Az.Migrate\Get-AzMigrateReplicationProtectionContainer @PSBoundParameters - $ProtectionContainerName = "" - if($peContainers -and ($peContainers.length -gt 0)){ - $ProtectionContainerName = $peContainers[0].Name - } - - if($ProtectionContainerName -eq ""){ - throw "Container not found for given resource group." - } - - $mappingName = "containermapping" - $null = $PSBoundParameters.Add('MappingName', $mappingName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - $mappingObject = Az.Migrate\Get-AzMigrateReplicationProtectionContainerMapping @PSBoundParameters -ErrorVariable notPresent -ErrorAction SilentlyContinue - if($mappingObject -and ($mappingObject.Count -ge 1)){ - $TargetRegion = $mappingObject.ProviderSpecificDetail.TargetLocation - }else{ - throw "The replication infrastructure is not initialized. Run the initialize-azmigratereplicationinfrastructure script again." - } - $null = $PSBoundParameters.Remove('MappingName') - - $HashCodeInput = $SiteName + $TargetRegion - $Source = @" -using System; -public class HashFunctions -{ -public static int hashForArtifact(String artifact) -{ - int hash = 0; - int al = artifact.Length; - int tl = 0; - char[] ac = artifact.ToCharArray(); - while (tl < al) - { - hash = ((hash << 5) - hash) + ac[tl++] | 0; - } - return Math.Abs(hash); -} -} -"@ - Add-Type -TypeDefinition $Source -Language CSharp - $hash = [HashFunctions]::hashForArtifact($HashCodeInput) - - $LogStorageAccountID = "/subscriptions/" + $SubscriptionId + "/resourceGroups/" + - $ResourceGroupName + "/providers/Microsoft.Storage/storageAccounts/migratelsa" + $hash - $LogStorageAccountSas = "migratelsa" + $hash + '-cacheSas' - if(!$HasTargetBDStorage){ - $TargetBootDiagnosticsStorageAccount = $LogStorageAccountID - } - if(!$HasResync){ - $PerformAutoResync = "true" - } - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("PolicyId", $PolicyId) - - $ProviderSpecificDetails = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtEnableMigrationInput]::new() - $ProviderSpecificDetails.DataMoverRunAsAccountId = $VMWarerunasaccountID - $ProviderSpecificDetails.SnapshotRunAsAccountId = $VMWarerunasaccountID - $ProviderSpecificDetails.InstanceType = 'VMwareCbt' - $ProviderSpecificDetails.LicenseType = $LicenseType - $ProviderSpecificDetails.PerformAutoResync = $PerformAutoResync - if($HasTargetAVSet){ - $ProviderSpecificDetails.TargetAvailabilitySetId = $TargetAvailabilitySet - } - if($HasTargetAVZone){ - $ProviderSpecificDetails.TargetAvailabilityZone = $TargetAvailabilityZone - } - $ProviderSpecificDetails.TargetBootDiagnosticsStorageAccountId = $TargetBootDiagnosticsStorageAccount - $ProviderSpecificDetails.TargetNetworkId = $TargetNetworkId - $ProviderSpecificDetails.TargetResourceGroupId = $TargetResourceGroupId - $ProviderSpecificDetails.TargetSubnetName = $TargetSubnetName - $ProviderSpecificDetails.TargetVMName = $TargetVMName - if($HasTargetVMSize){$ProviderSpecificDetails.TargetVMSize = $TargetVMSize} - $ProviderSpecificDetails.VmwareMachineId = $MachineId - - - if ($parameterSet -match 'DefaultUser'){ - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IVMwareCbtDiskInput[]]$DiskToInclude = @() - if($parameterSet -eq 'ByInputObjectDefaultUser'){ - foreach($onPremDisk in $InputObject.Disk){ - if($onPremDisk.Uuid -ne $OSDiskID){ - $DiskObject = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtDiskInput]::new() - $DiskObject.DiskId = $onPremDisk.Uuid - $DiskObject.DiskType = "Standard_LRS" - $DiskObject.IsOSDisk = "false" - $DiskObject.LogStorageAccountSasSecretName = $LogStorageAccountSas - $DiskObject.LogStorageAccountId = $LogStorageAccountID - if($HasDiskEncryptionSetID){ - $DiskObject.DiskEncryptionSetId = $DiskEncryptionSetID - } - $DiskToInclude+=$DiskObject - } - } - } - $DiskObject = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtDiskInput]::new() - $DiskObject.DiskId = $OSDiskID - $DiskObject.DiskType = $DiskType - $DiskObject.IsOSDisk = "true" - $DiskObject.LogStorageAccountSasSecretName = $LogStorageAccountSas - $DiskObject.LogStorageAccountId = $LogStorageAccountID - if($HasDiskEncryptionSetID){ - $DiskObject.DiskEncryptionSetId = $DiskEncryptionSetID - } - - $DiskToInclude+=$DiskObject - $ProviderSpecificDetails.DisksToInclude = $DiskToInclude - - }else{ - foreach ($DiskObject in $DiskToInclude) { - $DiskObject.LogStorageAccountSasSecretName = $LogStorageAccountSas - $DiskObject.LogStorageAccountId = $LogStorageAccountID - } - $ProviderSpecificDetails.DisksToInclude = $DiskToInclude - } - $null = $PSBoundParameters.add('ProviderSpecificDetail', $ProviderSpecificDetails) - $null = $PSBoundParameters.Add('NoWait', $true) - $output = Az.Migrate.internal\New-AzMigrateReplicationMigrationItem @PSBoundParameters - $JobName = $output.Target.Split("/")[12].Split("?")[0] - $null = $PSBoundParameters.Remove('NoWait') - $null = $PSBoundParameters.Remove('ProviderSpecificDetail') - $null = $PSBoundParameters.Remove("ResourceGroupName") - $null = $PSBoundParameters.Remove("ResourceName") - $null = $PSBoundParameters.Remove("FabricName") - $null = $PSBoundParameters.Remove("MigrationItemName") - $null = $PSBoundParameters.Remove("ProtectionContainerName") - $null = $PSBoundParameters.Remove("PolicyId") - - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - - } - -} \ No newline at end of file diff --git a/src/Migrate/custom/Remove-AzMigrateServerReplication.ps1 b/src/Migrate/custom/Remove-AzMigrateServerReplication.ps1 deleted file mode 100644 index 52a460f2e4d7..000000000000 --- a/src/Migrate/custom/Remove-AzMigrateServerReplication.ps1 +++ /dev/null @@ -1,144 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Stops replication for the migrated server. -.Description -The Remove-AzMigrateServerReplication cmdlet stops the replication for a migrated server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/remove-azmigrateserverreplication -#> -function Remove-AzMigrateServerReplication { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ByIDVMwareCbt', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='ByIDVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replcating server for which the replicatio needs to be disabled. The ID should be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${TargetObjectID}, - - [Parameter(ParameterSetName='ByInputObjectVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem] - # Specifies the machine object of the replicating server. - ${InputObject}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')] - [System.String] - # Specifies whether the replication needs to be force removed. - ${ForceRemove}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - $hasDeleteOption = $PSBoundParameters.ContainsKey('ForceRemove') - $null = $PSBoundParameters.Remove('ForceRemove') - $null = $PSBoundParameters.Remove('TargetObjectID') - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ProjectName') - $null = $PSBoundParameters.Remove('MachineName') - $null = $PSBoundParameters.Remove('InputObject') - $parameterSet = $PSCmdlet.ParameterSetName - - if($parameterSet -eq 'ByInputObjectVMwareCbt'){ - $TargetObjectID = $InputObject.Id - } - $MachineIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $MachineIdArray[4] - $VaultName = $MachineIdArray[8] - $FabricName = $MachineIdArray[10] - $ProtectionContainerName = $MachineIdArray[12] - $MachineName = $MachineIdArray[14] - - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("ResourceName", $VaultName) - $null = $PSBoundParameters.Add("FabricName", $FabricName) - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - if($hasDeleteOption){$null = $PSBoundParameters.Add('DeleteOption', $ForceRemove)} - $null = $PSBoundParameters.Add('NoWait', $true) - $output = Az.Migrate.internal\Remove-AzMigrateReplicationMigrationItem @PSBoundParameters - $JobName = $output.Target.Split("/")[12].Split("?")[0] - $null = $PSBoundParameters.Remove('NoWait') - $null = $PSBoundParameters.Remove('ProviderSpecificDetail') - $null = $PSBoundParameters.Remove("ResourceGroupName") - $null = $PSBoundParameters.Remove("ResourceName") - $null = $PSBoundParameters.Remove("FabricName") - $null = $PSBoundParameters.Remove("MigrationItemName") - $null = $PSBoundParameters.Remove("ProtectionContainerName") - - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - } -} \ No newline at end of file diff --git a/src/Migrate/custom/Restart-AzMigrateServerReplication.ps1 b/src/Migrate/custom/Restart-AzMigrateServerReplication.ps1 deleted file mode 100644 index 1b6442fdd057..000000000000 --- a/src/Migrate/custom/Restart-AzMigrateServerReplication.ps1 +++ /dev/null @@ -1,146 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Restarts the replication for specified server. -.Description -The Restart-AzMigrateServerReplication cmdlet repairs the replication for the specified server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/restart-azmigrateserverreplication -#> -function Restart-AzMigrateServerReplication{ - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ByIDVMwareCbt', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='ByIDVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replcating server for which the resync needs to be initiated. The ID should be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${TargetObjectID}, - - [Parameter(ParameterSetName='ByInputObjectVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem] - # Specifies the machine object of the replicating server. - ${InputObject}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - $null = $PSBoundParameters.Remove('TargetObjectID') - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ProjectName') - $null = $PSBoundParameters.Remove('MachineName') - $null = $PSBoundParameters.Remove('InputObject') - $parameterSet = $PSCmdlet.ParameterSetName - - if($parameterSet -eq 'ByInputObjectVMwareCbt'){ - $TargetObjectID = $InputObject.Id - } - $MachineIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $MachineIdArray[4] - $VaultName = $MachineIdArray[8] - $FabricName = $MachineIdArray[10] - $ProtectionContainerName = $MachineIdArray[12] - $MachineName = $MachineIdArray[14] - - - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("ResourceName", $VaultName) - $null = $PSBoundParameters.Add("FabricName", $FabricName) - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - $ReplicationMigrationItem = Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - if($ReplicationMigrationItem -and ($ReplicationMigrationItem.ProviderSpecificDetail.InstanceType -eq 'VMwarecbt')){ - $ProviderSepcificDetail = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtResyncInput]::new() - $ProviderSepcificDetail.InstanceType = 'VMwareCbt' - $ProviderSepcificDetail.SkipCbtReset = 'true' - $null = $PSBoundParameters.Add('ProviderSpecificDetail', $ProviderSepcificDetail) - $null = $PSBoundParameters.Add('NoWait', $true) - $output = Az.Migrate.internal\Invoke-AzMigrateResyncReplicationMigrationItem @PSBoundParameters - $JobName = $output.Target.Split("/")[12].Split("?")[0] - $null = $PSBoundParameters.Remove('NoWait') - $null = $PSBoundParameters.Remove('ProviderSpecificDetail') - $null = $PSBoundParameters.Remove("ResourceGroupName") - $null = $PSBoundParameters.Remove("ResourceName") - $null = $PSBoundParameters.Remove("FabricName") - $null = $PSBoundParameters.Remove("MigrationItemName") - $null = $PSBoundParameters.Remove("ProtectionContainerName") - - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - }else{ - throw "Either machine doesn't exist or provider/action isn't supported for this machine" - } - } -} \ No newline at end of file diff --git a/src/Migrate/custom/Set-AzMigrateServerReplication.ps1 b/src/Migrate/custom/Set-AzMigrateServerReplication.ps1 deleted file mode 100644 index b64a40163b23..000000000000 --- a/src/Migrate/custom/Set-AzMigrateServerReplication.ps1 +++ /dev/null @@ -1,265 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Updates the target properties for the replicating server. -.Description -The Set-AzMigrateServerReplication cmdlet updates the target properties for the replicating server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/set-azmigrateserverreplication -#> -function Set-AzMigrateServerReplication { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ByIDVMwareCbt', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='ByIDVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replcating server for which the properties need to be updated. The ID should be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${TargetObjectID}, - - [Parameter(ParameterSetName='ByInputObjectVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem] - # Specifies the replicating server for which the properties need to be updated. The server object can be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${InputObject}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replcating server for which the properties need to be updated. The ID should be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${TargetVMName}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Updates the SKU of the Azure VM to be created. - ${TargetVMSize}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Updates the Virtual Network id within the destination Azure subscription to which the server needs to be migrated. - ${TargetNetworkId}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Updates the Resource Group id within the destination Azure subscription to which the server needs to be migrated. - ${TargetResourceGroupID}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IVMwareCbtNicInput[]] - # Updates the NIC for the Azure VM to be created. - ${NicToUpdate}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Availability Set to be used for VM creation. - ${TargetAvailabilitySet}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the Availability Zone to be used for VM creation. - ${TargetAvailabilityZone}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # The subscription Id. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - - $HasTargetVMName = $PSBoundParameters.ContainsKey('TargetVMName') - $HasTargetVmSize = $PSBoundParameters.ContainsKey('TargetVMSize') - $HasTargetNetworkId = $PSBoundParameters.ContainsKey('TargetNetworkId') - $HasTargetResourceGroupID = $PSBoundParameters.ContainsKey('TargetResourceGroupID') - $HasNicToUpdate = $PSBoundParameters.ContainsKey('NicToUpdate') - $HasTargetAvailabilitySet = $PSBoundParameters.ContainsKey('TargetAvailabilitySet') - $HasTargetAvailabilityZone = $PSBoundParameters.ContainsKey('TargetAvailabilityZone') - - $null = $PSBoundParameters.Remove('TargetObjectID') - $null = $PSBoundParameters.Remove('TargetVMName') - $null = $PSBoundParameters.Remove('TargetVMSize') - $null = $PSBoundParameters.Remove('TargetNetworkId') - $null = $PSBoundParameters.Remove('TargetResourceGroupID') - $null = $PSBoundParameters.Remove('NicToUpdate') - $null = $PSBoundParameters.Remove('TargetAvailabilitySet') - $null = $PSBoundParameters.Remove('TargetAvailabilityZone') - $null = $PSBoundParameters.Remove('InputObject') - $parameterSet = $PSCmdlet.ParameterSetName - - if($parameterSet -eq 'ByInputObjectVMwareCbt'){ - $TargetObjectID = $InputObject.Id - } - $MachineIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $MachineIdArray[4] - $VaultName = $MachineIdArray[8] - $FabricName = $MachineIdArray[10] - $ProtectionContainerName = $MachineIdArray[12] - $MachineName = $MachineIdArray[14] - - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("ResourceName", $VaultName) - $null = $PSBoundParameters.Add("FabricName", $FabricName) - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - $ReplicationMigrationItem = Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - if($ReplicationMigrationItem -and ($ReplicationMigrationItem.ProviderSpecificDetail.InstanceType -eq 'VMwarecbt')){ - $ProviderSpecificDetails = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtUpdateMigrationItemInput]::new() - $ProviderSpecificDetails.InstanceType = 'VMwareCbt' - if($HasTargetAvailabilitySet){ $ProviderSpecificDetails.TargetAvailabilitySetId = $TargetAvailabilitySet } - if($HasTargetAvailabilityZone){ $ProviderSpecificDetails.TargetAvailabilityZone = $TargetAvailabilityZone } - if($HasTargetNetworkId){ $ProviderSpecificDetails.TargetNetworkId = $TargetNetworkId } - if($HasTargetVMName){ $ProviderSpecificDetails.TargetVMName = $TargetVMName } - if($HasTargetResourceGroupID){ $ProviderSpecificDetails.TargetResourceGroupId = $TargetResourceGroupID } - if($HasTargetVmSize){ $ProviderSpecificDetails.TargetVMSize = $TargetVmSize } - if($HasNicToUpdate){ - - $originalNics = $ReplicationMigrationItem.ProviderSpecificDetail.VMNic - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IVMwareCbtNicInput[]]$updateNicsArray = @() - - foreach ($storedNic in $originalNics) { - $updateNic = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtNicInput]::new() - $updateNic.IsPrimaryNic = $storedNic.IsPrimaryNic - $updateNic.IsSelectedForMigration = $storedNic.IsSelectedForMigration - $updateNic.NicId = $storedNic.NicId - $updateNic.TargetStaticIPAddress = $storedNic.TargetIPAddress - $updateNic.TargetSubnetName = $storedNic.TargetSubnetName - - $matchingUserInputNic = $null - foreach ($userInputNic in $NicToUpdate) { - if($userInputNic.NicId -eq $storedNic.NicId){ - $matchingUserInputNic = $userInputNic - break - } - } - if($matchingUserInputNic -ne $null){ - if($matchingUserInputNic.IsPrimaryNic -ne $null){ - $updateNic.IsPrimaryNic = $matchingUserInputNic.IsPrimaryNic - $updateNic.IsSelectedForMigration = $matchingUserInputNic.IsSelectedForMigration - if($updateNic.IsSelectedForMigration -eq "false"){ - $updateNic.TargetSubnetName = "" - $updateNic.TargetStaticIPAddress = "" - } - } - if($matchingUserInputNic.TargetSubnetName -ne $null){ - $updateNic.TargetSubnetName = $matchingUserInputNic.TargetSubnetName - } - if($matchingUserInputNic.TargetStaticIPAddress -ne $null){ - if($matchingUserInputNic.TargetStaticIPAddress -eq "auto"){ - $updateNic.TargetStaticIPAddress = $null - }else{ - $updateNic.TargetStaticIPAddress = $matchingUserInputNic.TargetStaticIPAddress - } - } - } - $updateNicsArray += $updateNic - } - - # validate there is exactly one primary nic - $primaryNicCountInUpdate = 0 - foreach($nic in $updateNicsArray){ - if($nic.IsPrimaryNic -eq "true"){ - $primaryNicCountInUpdate += 1 - } - } - if($primaryNicCountInUpdate -ne 1){ - throw "One NIC has to be Primary." - } - - $ProviderSpecificDetails.VMNic = $updateNicsArray - } - - $null = $PSBoundParameters.Add('ProviderSpecificDetail', $ProviderSpecificDetails) - $null = $PSBoundParameters.Add('NoWait', $true) - $output = Az.Migrate.internal\Update-AzMigrateReplicationMigrationItem @PSBoundParameters - $JobName = $output.Target.Split("/")[12].Split("?")[0] - - $null = $PSBoundParameters.Remove('NoWait') - $null = $PSBoundParameters.Remove('ProviderSpecificDetail') - $null = $PSBoundParameters.Remove("ResourceGroupName") - $null = $PSBoundParameters.Remove("ResourceName") - $null = $PSBoundParameters.Remove("FabricName") - $null = $PSBoundParameters.Remove("MigrationItemName") - $null = $PSBoundParameters.Remove("ProtectionContainerName") - - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - }else{ - throw "Either machine doesn't exist or provider/action isn't supported for this machine" - } - - } - -} \ No newline at end of file diff --git a/src/Migrate/custom/Start-AzMigrateServerMigration.ps1 b/src/Migrate/custom/Start-AzMigrateServerMigration.ps1 deleted file mode 100644 index 3f201558a765..000000000000 --- a/src/Migrate/custom/Start-AzMigrateServerMigration.ps1 +++ /dev/null @@ -1,160 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Starts the migration for the replicating server. -.Description -Starts the migration for the replicating server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/start-azmigraterservermigration -#> -function Start-AzMigrateServerMigration { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ByIDVMwareCbt', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='ByIDVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replcating server for which migration needs to be initiated. The ID should be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${TargetObjectID}, - - [Parameter(ParameterSetName='ByInputObjectVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem] - # Specifies the replicating server for which migration needs to be initiated. The server object can be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${InputObject}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.Management.Automation.SwitchParameter] - # Specifies whether the source server should be turned off post migration. - ${TurnOffSourceServer}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - if($TurnOffSourceServer.IsPresent){ - $PerformShutDown = "true" - }else{ - $PerformShutDown = "false" - } - $null = $PSBoundParameters.Remove('TurnOffSourceServer') - $null = $PSBoundParameters.Remove('TargetObjectID') - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ProjectName') - $null = $PSBoundParameters.Remove('MachineName') - $null = $PSBoundParameters.Remove('InputObject') - $parameterSet = $PSCmdlet.ParameterSetName - - - if($parameterSet -eq 'ByInputObjectVMwareCbt'){ - $TargetObjectID = $InputObject.Id - } - $MachineIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $MachineIdArray[4] - $VaultName = $MachineIdArray[8] - $FabricName = $MachineIdArray[10] - $ProtectionContainerName = $MachineIdArray[12] - $MachineName = $MachineIdArray[14] - - - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("ResourceName", $VaultName) - $null = $PSBoundParameters.Add("FabricName", $FabricName) - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - $ReplicationMigrationItem = Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - if($ReplicationMigrationItem -and ($ReplicationMigrationItem.ProviderSpecificDetail.InstanceType -eq 'VMwarecbt') -and ($ReplicationMigrationItem.AllowedOperation -contains 'Migrate' )){ - $ProviderSpecificDetailInput = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtMigrateInput]::new() - $ProviderSpecificDetailInput.InstanceType = 'VMwareCbt' - $ProviderSpecificDetailInput.PerformShutdown = $PerformShutDown - - $null = $PSBoundParameters.Add('ProviderSpecificDetail', $ProviderSpecificDetailInput) - $null = $PSBoundParameters.Add('NoWait', $true) - $output = Az.Migrate.internal\Move-AzMigrateReplicationMigrationItem @PSBoundParameters - $JobName = $output.Target.Split("/")[12].Split("?")[0] - $null = $PSBoundParameters.Remove('NoWait') - $null = $PSBoundParameters.Remove('ProviderSpecificDetail') - $null = $PSBoundParameters.Remove("ResourceGroupName") - $null = $PSBoundParameters.Remove("ResourceName") - $null = $PSBoundParameters.Remove("FabricName") - $null = $PSBoundParameters.Remove("MigrationItemName") - $null = $PSBoundParameters.Remove("ProtectionContainerName") - - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - }else{ - throw "Either machine doesn't exist or provider/action isn't supported for this machine" - } - } -} \ No newline at end of file diff --git a/src/Migrate/custom/Start-AzMigrateTestMigration.ps1 b/src/Migrate/custom/Start-AzMigrateTestMigration.ps1 deleted file mode 100644 index e59b720b05ef..000000000000 --- a/src/Migrate/custom/Start-AzMigrateTestMigration.ps1 +++ /dev/null @@ -1,158 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Starts the test migration for the replicating server. -.Description -The Start-AzMigrateTestMigration cmdlet initiates the test migration for the replicating server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/start-azmigratetestmigration -#> -function Start-AzMigrateTestMigration { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ByIDVMwareCbt', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='ByIDVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replicating server for which the test migration needs to be initiated. The ID should be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${TargetObjectID}, - - [Parameter(ParameterSetName='ByInputObjectVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem] - # Specifies the replicating server for which the test migration needs to be initiated. The server object can be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${InputObject}, - - [Parameter(Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Updates the Virtual Network id within the destination Azure subscription to be used for test migration. - ${TestNetworkID}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - $null = $PSBoundParameters.Remove('TargetObjectID') - $null = $PSBoundParameters.Remove('TestNetworkID') - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ProjectName') - $null = $PSBoundParameters.Remove('MachineName') - $null = $PSBoundParameters.Remove('InputObject') - $parameterSet = $PSCmdlet.ParameterSetName - - - if($parameterSet -eq 'ByInputObjectVMwareCbt'){ - $TargetObjectID = $InputObject.Id - } - $MachineIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $MachineIdArray[4] - $VaultName = $MachineIdArray[8] - $FabricName = $MachineIdArray[10] - $ProtectionContainerName = $MachineIdArray[12] - $MachineName = $MachineIdArray[14] - - - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("ResourceName", $VaultName) - $null = $PSBoundParameters.Add("FabricName", $FabricName) - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - $ReplicationMigrationItem = Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - if($ReplicationMigrationItem -and ($ReplicationMigrationItem.ProviderSpecificDetail.InstanceType -eq 'VMwarecbt') -and ($ReplicationMigrationItem.AllowedOperation -contains 'TestMigrate' )){ - $ProviderSpecificDetailInput = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.VMwareCbtTestMigrateInput]::new() - $ProviderSpecificDetailInput.InstanceType = 'VMwareCbt' - $ProviderSpecificDetailInput.NetworkId = $TestNetworkID - $ProviderSpecificDetailInput.RecoveryPointId = $ReplicationMigrationItem.ProviderSpecificDetail.LastRecoveryPointId - - $null = $PSBoundParameters.Add('ProviderSpecificDetail', $ProviderSpecificDetailInput) - $null = $PSBoundParameters.Add('NoWait', $true) - $output = Az.Migrate.internal\Test-AzMigrateReplicationMigrationItemMigrate @PSBoundParameters - $JobName = $output.Target.Split("/")[12].Split("?")[0] - $null = $PSBoundParameters.Remove('NoWait') - $null = $PSBoundParameters.Remove('ProviderSpecificDetail') - $null = $PSBoundParameters.Remove("ResourceGroupName") - $null = $PSBoundParameters.Remove("ResourceName") - $null = $PSBoundParameters.Remove("FabricName") - $null = $PSBoundParameters.Remove("MigrationItemName") - $null = $PSBoundParameters.Remove("ProtectionContainerName") - - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - }else{ - throw "Either machine doesn't exist or provider/action isn't supported for this machine" - } - - } - -} \ No newline at end of file diff --git a/src/Migrate/custom/Start-AzMigrateTestMigrationCleanup.ps1 b/src/Migrate/custom/Start-AzMigrateTestMigrationCleanup.ps1 deleted file mode 100644 index 60b4b177c987..000000000000 --- a/src/Migrate/custom/Start-AzMigrateTestMigrationCleanup.ps1 +++ /dev/null @@ -1,146 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Cleans up the test migration for the replicating server. -.Description -The Start-AzMigrateTestMigrationCleanup cmdlet initiates the clean up of the test migration for the replicating server. -.Link -https://docs.microsoft.com/en-us/powershell/module/az.migrate/start-azmigratetestmigrationcleanup -#> -function Start-AzMigrateTestMigrationCleanup { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])] - [CmdletBinding(DefaultParameterSetName='ByIDVMwareCbt', PositionalBinding=$false)] - param( - [Parameter(ParameterSetName='ByIDVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [System.String] - # Specifies the replicating server for which the test migration cleanup needs to be initiated. The ID should be retrieved using the Get-AzMigrateServerReplication cmdlet. - ${TargetObjectID}, - - [Parameter(ParameterSetName='ByInputObjectVMwareCbt', Mandatory)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IMigrationItem] - # Specifies the replicating server for which the test migration cleanup needs to be initiated. The server object can be retrieved using the Get-AzMigrateServerReplication cmdlet - ${InputObject}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Azure Subscription ID. - ${SubscriptionId}, - - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - ) - - process { - $null = $PSBoundParameters.Remove('TargetObjectID') - $null = $PSBoundParameters.Remove('ResourceGroupName') - $null = $PSBoundParameters.Remove('ProjectName') - $null = $PSBoundParameters.Remove('MachineName') - $null = $PSBoundParameters.Remove('InputObject') - $parameterSet = $PSCmdlet.ParameterSetName - - - if($parameterSet -eq 'ByInputObjectVMwareCbt'){ - $TargetObjectID = $InputObject.Id - } - $MachineIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $MachineIdArray[4] - $VaultName = $MachineIdArray[8] - $FabricName = $MachineIdArray[10] - $ProtectionContainerName = $MachineIdArray[12] - $MachineName = $MachineIdArray[14] - - - $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) - $null = $PSBoundParameters.Add("ResourceName", $VaultName) - $null = $PSBoundParameters.Add("FabricName", $FabricName) - $null = $PSBoundParameters.Add("MigrationItemName", $MachineName) - $null = $PSBoundParameters.Add("ProtectionContainerName", $ProtectionContainerName) - - $ReplicationMigrationItem = Az.Migrate.internal\Get-AzMigrateReplicationMigrationItem @PSBoundParameters - if($ReplicationMigrationItem -and ($ReplicationMigrationItem.ProviderSpecificDetail.InstanceType -eq 'VMwarecbt')){ - - $null = $PSBoundParameters.Add('Comment', "Test migrate cleanup from powershell") - $null = $PSBoundParameters.Add('NoWait', $true) - $output = Az.Migrate.internal\Test-AzMigrateReplicationMigrationItemMigrateCleanup @PSBoundParameters - $JobName = $output.Target.Split("/")[12].Split("?")[0] - $null = $PSBoundParameters.Remove('NoWait') - $null = $PSBoundParameters.Remove('ProviderSpecificDetail') - $null = $PSBoundParameters.Remove("ResourceGroupName") - $null = $PSBoundParameters.Remove("ResourceName") - $null = $PSBoundParameters.Remove("FabricName") - $null = $PSBoundParameters.Remove("MigrationItemName") - $null = $PSBoundParameters.Remove("ProtectionContainerName") - $null = $PSBoundParameters.Remove('Comment') - - $null = $PSBoundParameters.Add('JobName', $JobName) - $null = $PSBoundParameters.Add('ResourceName', $VaultName) - $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) - - return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters - }else{ - throw "Operation Not supported" - } - } -} \ No newline at end of file