用于搜索和删除文件夹和子文件夹的Powershell命令/脚本

时间:2016-12-13 07:24:13

标签: windows powershell batch-file cmd

美好的一天,我在互联网上搜索一个powershell命令/脚本,可以在远程机器上搜索和删除任何名为(Games *)(游戏*)的文件夹 在CMD我习惯命令" del / s \ computername \ c $ \ Game *"并且它与我完美配合,但它只删除文件,需要一个可以删除文件和文件夹的powershell脚本。

2 个答案:

答案 0 :(得分:1)

Remove-Item \\compname1\c$\Game* -force -recurse

答案 1 :(得分:0)

在powershell中使用管道选项.Below代码将完成工作。

get-childitem -path 'FilePath' -Recurse  -Filter "Game*" | remove-item  -Force

希望它能够发挥作用。