-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expand file tree
/
Copy pathNew-AzMigrateLocalDiskMappingObject.ps1
More file actions
94 lines (83 loc) · 3.76 KB
/
New-AzMigrateLocalDiskMappingObject.ps1
File metadata and controls
94 lines (83 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# ----------------------------------------------------------------------------------
#
# 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-AzMigrateLocalDiskMappingObject cmdlet creates a mapping of the source disk attached to the server to be migrated
.Link
https://learn.microsoft.com/powershell/module/az.migrate/new-azmigratelocaldiskmappingobject
#>
function New-AzMigrateLocalDiskMappingObject {
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.PreviewMessageAttribute("This cmdlet is based on a preview API version and may experience breaking changes in future releases.")]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20260201.AzLocalDiskInput])]
[CmdletBinding(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)]
[ValidateSet("true" , "false")]
[ArgumentCompleter( { "true" , "false" })]
[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)]
[ValidateSet("true" , "false")]
[ArgumentCompleter( { "true" , "false" })]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Specifies whether the disk is dynamic.
${IsDynamic},
[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.Int64]
# Specifies the disk size in GB.
${Size},
[Parameter(Mandatory)]
[ValidateSet("VHD", "VHDX")]
[ArgumentCompleter( { "VHD", "VHDX" })]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Specifies the disk format. 'VHD' or 'VHDX' for Hyper-V Generation 1; 'VHDX' for Hyper-V Generation 2.
${Format},
[Parameter()]
[ValidateSet("512", "4096")]
[ArgumentCompleter( { "512", "4096" })]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.Int64]
# Specifies the disk physical sector size in bytes.
${PhysicalSectorSize}
)
process {
$isDynamicDisk = [System.Convert]::ToBoolean($IsDynamic)
$osDisk = [System.Convert]::ToBoolean($IsOSDisk)
$hasPhysicalSectorSize = $PSBoundParameters.ContainsKey('PhysicalSectorSize')
if ($Format -eq "VHD" -and $hasPhysicalSectorSize -and $PhysicalSectorSize -ne 512) {
throw "PhysicalSectorSize must be 512 for VHD format but $PhysicalSectorSize is given."
}
$DiskObject = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20260201.AzLocalDiskInput]::new(
$DiskID,
$isDynamicDisk,
$Size,
$Format,
$osDisk,
$PhysicalSectorSize
)
return $DiskObject
}
}