检查磁盘空间占百分比,若≥80%,则将本机IP和盘符添加到网络路径上的记事本里,批处理可以实现吗?

2025-03-12 15:13:42
推荐回答(1个)
回答1:

$i=(Get-WmiObject -Class Win32_networkadapterconfiguration -Filter ipenabled=true).ipaddress
Get-WmiObject -erroraction silentlycontinue win32_logicaldisk -filter "drivetype = 3" |% {
if ((($_.size-$_.freespace)/$_.size*100).tostring("f2") -gt 80)
{
write $i $_.deviceid 使用空间超过80% >>\\192.168.1.111\temp.txt

}
else
{
}
}