【发布时间】:2015-12-07 02:46:41
【问题描述】:
# Locate Local HDD drive letter (100GB+)
#(Get-WmiObject -Query "SELECT * FROM Win32_LogicalDisk WHERE DriveType LIKE 3" | Sort-Object -Descending Size)[0] | Format-List *
$oLocalLargestHDD = (Get-WmiObject -Query "SELECT * FROM Win32_LogicalDisk WHERE DriveType LIKE 3" | Sort-Object -Descending Size)[0]
If ($oLocalLargestHDD.Size -gt 100000000)
{
$sMsg = "HDD ( $oLocalLargestHDD.Name ) is found!"
Write-Host $sMsg
} else {
Write-Host "HDD is NOT found!"
}
输出:
找到硬盘(\BRIANG\root\cimv2:Win32_LogicalDisk.DeviceID="C:".Name)!
而不是
找到硬盘 (C:)!
【问题讨论】:
-
$sMsg = "HDD $($oLocalLargestHDD.Name) is found!"
标签: string powershell wmi powershell-2.0