Is there any cmdlet way to get if a Disk is fixed or removable given a code like this?
$disk = Get-Disk -Number 1
Get-DiskDriveType $disk
Where Get-DiskDriveType
should return either Removable
or Fixed
.
Is there any cmdlet way to get if a Disk is fixed or removable given a code like this?
$disk = Get-Disk -Number 1
Get-DiskDriveType $disk
Where Get-DiskDriveType
should return either Removable
or Fixed
.
Inventory Drive Types by Using PowerShell
Two methods:
Get-Volume
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus SizeRemaining Size
----------- ----------- ---------- --------- ---------- ---------- ----
C SSD NTFS Fixed Healthy 75.38 GB 148.53 GB
E HybridTe... NTFS Fixed Healthy 560.71 GB 931.39 GB
D FourTB_B... NTFS Fixed Healthy 1.5 TB 3.64 TB
F TwoTB_BU... NTFS Fixed Healthy 204.34 GB 1.82 TB
G USB3 NTFS Removable Healthy 6.73 GB 58.89 GB
Recovery NTFS Fixed Healthy 22.96 MB 300 MB
H CD-ROM Healthy 0 B 0 B
Or
$hash = @{
2 = "Removable disk"
3 = "Fixed local disk"
4 = "Network disk"
5 = "Compact disk"
}
Get-CimInstance Win32_LogicalDisk |
Select DeviceID, VolumeName,
@{LABEL='TypeDrive';EXPRESSION={$hash.item([int]$_.DriveType)}}
Get-Volume | Where-Object {$_.DriveType -eq 'removable'} | Get-Partition | Get-Disk | Where-Object {$_.Number -eq $diskNumber}
The Bustype property returned by Get-Disk was good for my needs. I didn't have volumes on my disks yet so the Get-Volume wouldn't work for me. This is what I used:
$USBDisks = Get-Disk | Where-Object -FilterScript {$_.Bustype -eq "USB"}