Created
August 27, 2024 15:27
-
-
Save huevos-y-bacon/c853c91646f911a36cd79164854586b5 to your computer and use it in GitHub Desktop.
PowerShell - Commands to show drive details, including EBS volume IDs, on an Amazon EC2 instance
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
# PowerShell - Commands to show drive details, including EBS volume IDs, on an Amazon EC2 instance | |
Get-Volume | |
# Output: | |
# DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size | |
# ----------- ------------ -------------- --------- ------------ ----------------- ------------- ---- | |
# C NTFS Fixed Healthy OK 43.33 GB 100 GB | |
# D Swap NTFS Fixed Healthy OK 49.9 GB 50 GB | |
# E AppLogs NTFS Fixed Healthy OK 49.9 GB 50 GB | |
# F Master NTFS Fixed Healthy OK 9.2 GB 10 GB | |
# G Data NTFS Fixed Healthy OK 432.84 GB 1.95 TB | |
# H Logs NTFS Fixed Healthy OK 769.74 GB 800 GB | |
# I Temp NTFS Fixed Healthy OK 21.64 GB 50 GB | |
# J Backups NTFS Fixed Healthy OK 1.51 TB 1.95 TB | |
# Y Scratch 1 NTFS Fixed Healthy OK 79.9 GB 80 GB | |
# Z Scratch 2 NTFS Fixed Healthy OK 79.9 GB 80 GB | |
DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size | |
----------- ------------ -------------- --------- ------------ ----------------- ------------- ---- | |
I Temp NTFS Fixed Healthy OK 21.64 GB 50 GB | |
Y Local Disk NTFS Fixed Healthy OK 79.9 GB 80 GB | |
Z Local Disk NTFS Fixed Healthy OK 79.9 GB 80 GB | |
gdr -PSProvider 'FileSystem' | |
# Output: | |
# Name Used (GB) Free (GB) Provider Root CurrentLocation | |
# ---- --------- --------- -------- ---- --------------- | |
# C 56.66 43.33 FileSystem C:\ Windows\system32 | |
# D 0.10 49.90 FileSystem D:\ | |
# E 0.10 49.90 FileSystem E:\ | |
# F 0.80 9.20 FileSystem F:\ | |
# G 1567.16 432.84 FileSystem G:\ | |
# H 30.26 769.74 FileSystem H:\ | |
# I 28.35 21.64 FileSystem I:\ | |
# J 458.27 1541.73 FileSystem J:\ | |
# Y 0.10 79.90 FileSystem Y:\ | |
# Z 0.10 79.90 FileSystem Z:\ | |
Get-PhysicalDisk | |
# Output: | |
# Number FriendlyName SerialNumber MediaType CanPool OperationalStatus HealthStatus Usage Size | |
# ------ ------------ ------------ --------- ------- ----------------- ------------ ----- ---- | |
# 0 NVMe Amazon Elastic B vol1234567880f7d0447_00000001. SSD False OK Healthy Auto-Select 100 GB | |
# 1 NVMe Amazon Elastic B vol123456789e9b37c78_00000001. SSD False OK Healthy Auto-Select 80 GB | |
# 2 NVMe Amazon Elastic B vol12345678bcf798a4f_00000001. SSD False OK Healthy Auto-Select 50 GB | |
# 3 NVMe Amazon Elastic B vol12345678c44acc02f_00000001. SSD False OK Healthy Auto-Select 800 GB | |
# 4 NVMe Amazon Elastic B vol12345678d1aa7d6df_00000001. SSD False OK Healthy Auto-Select 1.95 TB | |
# 5 NVMe Amazon Elastic B vol1234567812a19b0be_00000001. SSD False OK Healthy Auto-Select 10 GB | |
# 6 NVMe Amazon Elastic B vol123456783fd783fe5_00000001. SSD False OK Healthy Auto-Select 80 GB | |
# 7 NVMe Amazon Elastic B vol12345678d82ab1f8e_00000001. SSD False OK Healthy Auto-Select 50 GB | |
# 8 NVMe Amazon Elastic B vol12345678f70120c97_00000001. SSD False OK Healthy Auto-Select 1.95 TB | |
# 9 NVMe Amazon Elastic B vol1234567870fc78bc2_00000001. SSD False OK Healthy Auto-Select 50 GB | |
# DISPLAY THE DISKID AND DRIVELETTER FOR EACH DISK | |
$Disks = Get-PhysicalDisk | foreach { | |
$DiskID = $_.SerialNumber.Split('_')[0].Replace('vol','vol-') | |
$Letter = (Get-Partition -DiskNumber $_.DeviceID).DriveLetter | where {$_} | |
[pscustomobject] @{ | |
Letter = $Letter | |
DiskID = $DiskID | |
} | |
} | |
$Disks | |
# One-liner: | |
Get-PhysicalDisk | foreach { $DiskID = $_.SerialNumber.Split('_')[0].Replace('vol','vol-'); $Letter = (Get-Partition -DiskNumber $_.DeviceID).DriveLetter | where {$_}; [pscustomobject] @{ Letter = $Letter; DiskID = $DiskID } } | |
# Output: | |
# Letter DiskID | |
# ------ ------ | |
# C vol-1234567880f7d0447 | |
# D vol-12345678bcf798a4f | |
# E vol-12345678d82ab1f8e | |
# F vol-1234567812a19b0be | |
# G vol-12345678d1aa7d6df | |
# H vol-12345678c44acc02f | |
# I vol-1234567870fc78bc2 | |
# J vol-12345678f70120c97 | |
# Y vol-123456783fd783fe5 | |
# Z vol-123456789e9b37c78 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment