enter image description here我正在编写脚本来检查HD的状态,当我执行脚本并完成HD = 1脚本的数量时,但是当HD的大于1的数字不能正确显示信息时(当我删除-Filter“DriveType = 3”时:
foreach ($servidor in $servidores) {
$diskinfo = Get-WmiObject Win32_LogicalDisk -ComputerName $servidor -Filter "DriveType=3" | Select-Object DeviceID, Size, FreeSpace
foreach ($disk in $diskinfo) {
$i += "<tr>"
$i += "<td>$($servidor)</td>"
$i += "<td>$($diskinfo.DeviceID)</td>"
$i += "<td>$([Math]::Truncate($diskinfo.Size / $convertirGB)) GB </td>"
$i += "<td>$([Math]::Truncate($diskinfo.FreeSpace / $convertirGB)) GB </td>"
if([Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100) -le 15) {
$i += "<td><font color=red> $([Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100)) % </font></td></tr>"
}
if([Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100) -gt 25 -and [Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100) -le 20){
$i += "<td><font color=orange> $([Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100)) % </font></td></tr>"
}
if([Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100) -gt 35){
$i += "<td><font color=green> $([Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100)) % </font></td></tr>"
}
}
}
非常感谢: - )
答案 0 :(得分:1)
您指的是循环中的$disk
(即整个磁盘集合),而不是if([Math]::Truncate(($diskinfo.FreeSpace / $diskinfo.size) * 100)
(集合中的单个磁盘)。
例如,替换此行:
if([Math]::Truncate(($disk.FreeSpace / $disk.size) * 100)
使用:
DeleteByQueryRequestBuilder deleteRequest = DeleteByQueryRequestBuilder(esType, DeleteByQueryAction.INSTANCE)
.setIndices(index)
.setTypes(type);
deleteRequest.setQuery(boolQuery);
DeleteByQueryResponse resp = deleteRequest.get();