Skip to content

Instantly share code, notes, and snippets.

@bcdejp
Created January 18, 2021 11:06
Show Gist options
  • Save bcdejp/1e33afff203270581d0f9ac80e3922a8 to your computer and use it in GitHub Desktop.
Save bcdejp/1e33afff203270581d0f9ac80e3922a8 to your computer and use it in GitHub Desktop.
PowerShell Partition
# SDカードに規定のパーティションを作製する
$partitionStyle = "MBR";
$partitionSize1 = 1073741824;
$driveLetter1 = "J"
$driveLetter2 = "K";
$driveLetter3 = "L";
$driveLetter4 = "M";
$driveLetter5 = "N";
$wsobj = new-object -comobject wscript.shell
Get-Disk |
where PartitionStyle -match $partitionStyle |
Clear-Disk -RemoveData -RemoveOEM -PassThru |
#Initialize-Disk -PartitionStyle MBR -PassThru | # これいるのか?
New-Partition -MbrType FAT32 -Size $partitionSize1 -DriveLetter $driveLetter1 | # プライマリパーティション1
New-Partition -MbrType FAT32 -Size $partitionSize1 -DriveLetter $driveLetter2 | # プライマリパーティション2
New-Partition -MbrType Extended -UseMaximumSize | # 拡張割り当て
New-Partition -MbrType FAT32 -Size $partitionSize1 -DriveLetter $driveLetter3 | # 論理パーティション1
New-Partition -MbrType FAT32 -Size $partitionSize1 -DriveLetter $driveLetter4 | # 論理パーティション2
New-Partition -MbrType FAT32 -UseMaximumSize -DriveLetter $driveLetter5 ; # 論理パーティション3
Get-Partition -DriveLetter $driveLetter1 | Format-Volume -FileSystem FAT32 -NewFileSystemLabel A;
Get-Partition -DriveLetter $driveLetter2 | Format-Volume -FileSystem FAT32 -NewFileSystemLabel B;
Get-Partition -DriveLetter $driveLetter3 | Format-Volume -FileSystem FAT32 -NewFileSystemLabel C;
Get-Partition -DriveLetter $driveLetter4 | Format-Volume -FileSystem FAT32 -NewFileSystemLabel D;
Get-Partition -DriveLetter $driveLetter5 | Format-Volume -FileSystem FAT32 -NewFileSystemLabel E;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment