-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConvert-DpDisk.ps1
44 lines (37 loc) · 1.1 KB
/
Convert-DpDisk.ps1
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
<#
.SYNOPSIS
Converts a disk to the specified disk type using Diskpart.
.DESCRIPTION
The Convert-DpDisk function converts a disk to the specified disk type using Diskpart utility. It takes the DiskNumber and DiskType as parameters.
.PARAMETER DiskNumber
The disk number of the disk to be converted.
.PARAMETER DiskType
The type of disk to convert to. Valid values are 'GPT', 'MBR', 'Dynamic', and 'Basic'. The default value is 'GPT'.
.EXAMPLE
Convert-DpDisk -DiskNumber 1 -DiskType MBR
Converts disk number 1 to MBR disk type.
.EXAMPLE
Convert-DpDisk -DiskNumber 2 -DiskType Dynamic
Converts disk number 2 to Dynamic disk type.
#>
Function Convert-DpDisk {
[cmdletbinding()]
param(
[Int]
[Parameter(ValueFromPipeline = $true,
ValueFromPipelinebyPropertyName = $true,
Mandatory = $true)]
$DiskNumber,
[ValidateSet('GPT', 'MBR', 'Dynamic', 'Basic')]
$DiskType = 'GPT'
)
Process {
$DiskpartCommand = @"
Select Disk $DiskNumber
Convert $DiskType
"@
Write-Verbose $DiskpartCommand
$DiskpartCommand | diskpart.exe
Write-Verbose -Message $ReturnValue[-1]
}
}