Is it possible to do this powershell script in plane old wmic commands? I need to get disk model info based off a path or drive letter if possible but am having issues running powershell scripts.
Get-WmiObject Win32_DiskDrive | % {
$disk = $_
$partitions = "ASSOCIATORS OF " +
"{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " +
"WHERE AssocClass = Win32_DiskDriveToDiskPartition"
Get-WmiObject -Query $partitions | % {
$partition = $_
$drives = "ASSOCIATORS OF " +
"{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " +
"WHERE AssocClass = Win32_LogicalDiskToPartition"
Get-WmiObject -Query $drives | % {
New-Object -Type PSCustomObject -Property @{
Disk = $disk.DeviceID
DiskSize = $disk.Size
DiskModel = $disk.Model
Partition = $partition.Name
RawSize = $partition.Size
DriveLetter = $_.DeviceID
VolumeName = $_.VolumeName
Size = $_.Size
FreeSpace = $_.FreeSpace
}
}
}
}
Script was shared in this question: Combine `Get-Disk` info and `LogicalDisk` info in PowerShell?
I'm not sure I understand:
wmic is for making single, simple queries.
If you want to make more sophisticated queries (for example, the nested loops above), you're going to need some kind of "programming language". Like C#, VBScript ... or Powershell.
Q: What exactly are the "problems" you've encountered trying to execute this script?
Here is sample output from your script:
PS:
See also PowerShell says "execution of scripts is disabled on this system."