1
votes

Here's my powerShell "piped" command

Get-Disk |
Where partitionstyle -eq 'raw' |
Initialize-Disk -PartitionStyle MBR -PassThru |
New-Partition -AssignDriveLetter -UseMaximumSize -DriveLetter Z |
Format-Volume -FileSystem NTFS -NewFileSystemLabel "ephemeral" -Confirm:$false

It complains about the DriveLetter parameter.

New-Partition : Invalid Parameter Activity ID: {e3ec7f8a-a672-4c81-a149-9440244ca230} At line:7 char:1 + New-Partition -AssignDriveLetter -UseMaximumSize -DriveLetter "Z" | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (StorageWMI:ROOT/Microsoft/Windows/Storage/MSFT_Disk) [New-Partition], CimException + FullyQualifiedErrorId : StorageWMI 5,New-Partition

The following script without it works just fine. I'm out of ideas...

Get-Disk |
Where partitionstyle -eq 'raw' |
Initialize-Disk -PartitionStyle MBR -PassThru |
New-Partition -AssignDriveLetter -UseMaximumSize |
Format-Volume -FileSystem NTFS -NewFileSystemLabel "ephemeral" -Confirm:$false
1

1 Answers

3
votes

UPDATE: OK seems like you can't use DriveLetter and AssignDriveLetter at the same time, MS docs are very unclear about this.

It should be

New-Partition -UseMaximumSize -DriveLetter Z |