測試服務器只有C盤,固定大小,多人共享,每月重啟升級,有時候會出現(xiàn)磁盤空間不足的問題,所有需要查找某臺服務器上的大文件
Get-ChildItem "c:" -Recurse | sort -descending -property length | select -first 10 name, Length
可以說,相當慢了......
最直觀的就是排除C:Windows
文件夾,然后再遞歸遍歷其他文件(夾),看一下
Get-ChildItem "c:" -Exclude "Windows"
運行了沒輸出。
難道Exclude的使用方式不對嗎?
說明使用沒有問題,可是why?
google了下,看到有人給官方提的issue,官方也標記為Bug了。
https://github.com/PowerShell/PowerShell/issues/11649
https://stackoverflow.com/questions/38269209/using-get-childitem-exclude-or-include-returns-nothing/38308796
Get-ChildItem "c:" -Exclude "Windows"
替換為
Get-Item c:* -Exclude "Windows"
Get-Item c:* -Exclude "Windows" | Get-ChildItem -Recurse | sort -descending -property length | select -first 10 name, Length