1+
2+ # ----------------------------------------------------------------------------------
3+ #
4+ # Copyright Microsoft Corporation
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+ # ----------------------------------------------------------------------------------
15+
16+ <#
17+ . Synopsis
18+ Retrieves the status of an Azure Migrate job.
19+ . Description
20+ The Get-AzMigrateJob cmdlet retrives the status of an Azure Migrate job.
21+ . Link
22+ https://docs.microsoft.com/en-us/powershell/module/az.migrate/get-azmigratejob
23+ #>
24+ function Get-AzMigrateJob {
25+ [OutputType ([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob ])]
26+ [CmdletBinding (DefaultParameterSetName = ' ListByName' , PositionalBinding = $false )]
27+ param (
28+ [Parameter (ParameterSetName = ' GetById' , Mandatory )]
29+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
30+ [System.String ]
31+ # Specifies the job id for which the details needs to be retrieved.
32+ ${JobID} ,
33+
34+ [Parameter (ParameterSetName = ' GetByName' , Mandatory )]
35+ [Parameter (ParameterSetName = ' ListByName' , Mandatory )]
36+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
37+ [System.String ]
38+ # The name of the resource group where the recovery services vault is present.
39+ ${ResourceGroupName} ,
40+
41+ [Parameter (ParameterSetName = ' GetByName' , Mandatory )]
42+ [Parameter (ParameterSetName = ' ListByName' , Mandatory )]
43+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
44+ [System.String ]
45+ # The name of the migrate project.
46+ ${ProjectName} ,
47+
48+ [Parameter (ParameterSetName = ' GetByName' , Mandatory )]
49+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
50+ [System.String ]
51+ # Job identifier
52+ ${JobName} ,
53+
54+ [Parameter (ParameterSetName = ' GetByInputObject' , Mandatory )]
55+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
56+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob ]
57+ # Specifies the job object of the replicating server.
58+ ${InputObject} ,
59+
60+ [Parameter (ParameterSetName = ' ListById' , Mandatory )]
61+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
62+ [System.String ]
63+ # Specifies the Resource Group of the Azure Migrate Project in the current subscription.
64+ ${ResourceGroupID} ,
65+
66+ [Parameter (ParameterSetName = ' ListById' , Mandatory )]
67+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
68+ [System.String ]
69+ # Specifies the Azure Migrate Project in which servers are replicating.
70+ ${ProjectID} ,
71+
72+ [Parameter (ParameterSetName = ' ListByName' )]
73+ [Parameter (ParameterSetName = ' ListById' )]
74+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Query' )]
75+ [System.String ]
76+ # OData filter options.
77+ ${Filter} ,
78+
79+ [Parameter ()]
80+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Path' )]
81+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo (Script= ' (Get-AzContext).Subscription.Id' )]
82+ [System.String ]
83+ # Azure Subscription ID.
84+ ${SubscriptionId} ,
85+
86+ [Parameter ()]
87+ [Alias (' AzureRMContext' , ' AzureCredential' )]
88+ [ValidateNotNull ()]
89+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Azure' )]
90+ [System.Management.Automation.PSObject ]
91+ # The credentials, account, tenant, and subscription used for communication with Azure.
92+ ${DefaultProfile} ,
93+
94+ [Parameter (DontShow)]
95+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Runtime' )]
96+ [System.Management.Automation.SwitchParameter ]
97+ # Wait for .NET debugger to attach
98+ ${Break} ,
99+
100+ [Parameter (DontShow)]
101+ [ValidateNotNull ()]
102+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Runtime' )]
103+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep []]
104+ # SendAsync Pipeline Steps to be appended to the front of the pipeline
105+ ${HttpPipelineAppend} ,
106+
107+ [Parameter (DontShow)]
108+ [ValidateNotNull ()]
109+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Runtime' )]
110+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep []]
111+ # SendAsync Pipeline Steps to be prepended to the front of the pipeline
112+ ${HttpPipelinePrepend} ,
113+
114+ [Parameter (DontShow)]
115+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Runtime' )]
116+ [System.Uri ]
117+ # The URI for the proxy server to use
118+ ${Proxy} ,
119+
120+ [Parameter (DontShow)]
121+ [ValidateNotNull ()]
122+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Runtime' )]
123+ [System.Management.Automation.PSCredential ]
124+ # Credentials for a proxy server to use for the remote call
125+ ${ProxyCredential} ,
126+
127+ [Parameter (DontShow)]
128+ [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category (' Runtime' )]
129+ [System.Management.Automation.SwitchParameter ]
130+ # Use the default credentials for the proxy
131+ ${ProxyUseDefaultCredentials}
132+ )
133+
134+ process {
135+ $parameterSet = $PSCmdlet.ParameterSetName
136+ $null = $PSBoundParameters.Remove (' JobID' )
137+ $null = $PSBoundParameters.Remove (' ResourceGroupName' )
138+ $null = $PSBoundParameters.Remove (' ProjectName' )
139+ $null = $PSBoundParameters.Remove (' JobName' )
140+ $null = $PSBoundParameters.Remove (' InputObject' )
141+ $null = $PSBoundParameters.Remove (' InputServerObject' )
142+ $null = $PSBoundParameters.Remove (' ResourceGroupID' )
143+ $null = $PSBoundParameters.Remove (' ProjectID' )
144+ $HasFilter = $PSBoundParameters.ContainsKey (' Filter' )
145+ $null = $PSBoundParameters.Remove (' Filter' )
146+
147+
148+ if (($parameterSet -match ' Name' ) -or ($parameterSet -eq ' ListById' )){
149+ if ($parameterSet -eq ' ListById' ){
150+ $ProjectName = $ProjectID.Split (" /" )[8 ]
151+ $ResourceGroupName = $ResourceGroupID.Split (" /" )[4 ]
152+ }
153+ $null = $PSBoundParameters.Add (" ResourceGroupName" , $ResourceGroupName )
154+ $null = $PSBoundParameters.Add (" Name" , " Servers-Migration-ServerMigration" )
155+ $null = $PSBoundParameters.Add (" MigrateProjectName" , $ProjectName )
156+
157+ $solution = Az.Migrate\Get-AzMigrateSolution @PSBoundParameters
158+ if ($solution -and ($solution.Count -ge 1 )){
159+ $ResourceName = $solution.DetailExtendedDetail.AdditionalProperties.vaultId.Split (" /" )[8 ]
160+ }else {
161+ throw " Solution not found."
162+ }
163+ $null = $PSBoundParameters.Remove (" Name" )
164+ $null = $PSBoundParameters.Remove (" MigrateProjectName" )
165+ $null = $PSBoundParameters.Remove (" ResourceGroupName" )
166+ }else {
167+ if ($parameterSet -eq ' GetByInputObject' ){
168+ $JobID = $InputObject.Id
169+ }
170+ $JobIdArray = $JobID.split (' /' )
171+ $JobName = $JobIdArray [10 ]
172+ $ResourceName = $JobIdArray [8 ]
173+ $ResourceGroupName = $JobIdArray [4 ]
174+ }
175+
176+ if ($parameterSet -match ' Get' ){
177+ $null = $PSBoundParameters.Add (' JobName' , $JobName )
178+ $null = $PSBoundParameters.Add (' ResourceName' , $ResourceName )
179+ $null = $PSBoundParameters.Add (' ResourceGroupName' , $ResourceGroupName )
180+
181+ return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters
182+ }else {
183+ $null = $PSBoundParameters.Add (' ResourceName' , $ResourceName )
184+ $null = $PSBoundParameters.Add (' ResourceGroupName' , $ResourceGroupName )
185+ if ($HasFilter ){$null = $PSBoundParameters.Add (' Filter' , $Filter )}
186+
187+ return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters
188+ }
189+
190+
191+ }
192+ }
0 commit comments