Last active
May 5, 2020 22:26
-
-
Save ThePVD/00dfcbf72be5f5f2c14dab39d1c50e3b to your computer and use it in GitHub Desktop.
Powershell: Windows EC2 - find and format an ephemeral NVMe drive if not already active
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This script will identify a single ephemeral disk presented to windows and format it w/64k blocksize and TEMPORARY label. | |
#Created by DTH 5/4/20 | |
#Identify disk with Friendly Name indicating Ephemeral | |
$disknum = get-disk |where-object {$_.FriendlyName -eq 'NVMe Amazon EC2 NVMe'}| select-object -ExpandProperty Number | |
#Check to make sure disk is RAW, if so format / label | |
$operationalstatus = get-disk $disknum | Select-Object -ExpandProperty OperationalStatus | |
$partitionstyle = get-disk $disknum | Select-Object -ExpandProperty PartitionStyle | |
if ( $partitionstyle -eq 'RAW' ) { | |
Initialize-Disk -Number $disknum | |
new-partition -DiskNumber $disknum -UseMaximumSize -DriveLetter T | Format-Volume -FileSystem NTFS -NewFilesystemLabel TEMPORARY -AllocationUnitSize 65536 –Force -Confirm:$false | |
} | |
else { write-output "no RAW ephemeral disks found" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment