Power Shell脚本将删除文件夹和子文件夹上的日志

时间:2012-01-10 14:37:29

标签: powershell powershell-v2.0

致电Power Shell Guru =)

有人可以帮我创建电源shell脚本,删除文件夹上的日志文件,包括子文件夹上的日志吗?

1 个答案:

答案 0 :(得分:2)

假设您想要删除变量logpath中指定的目录的扩展日志的所有文件:

$logpath = "C:\ExamplePath\MyLogFiles"
Get-ChildItem $logpath -recurse *.log -force | Remove-Item -force