Powershell remove-item无法正常工作

时间:2012-07-15 09:14:05

标签: powershell

为什么

dir E:\Music -File -Exclude *.mp3 -Recurse | foreach {del $_.FullName}

不工作?我测试了我能想到的所有可能性,但仍然没有用。

提前致谢。

3 个答案:

答案 0 :(得分:4)

我有同样的问题,我使用以下方法来修复它:

dir E:\Music -File -Exclude *.mp3 -Recurse | Remove-Item

答案 1 :(得分:3)

该命令看起来不错,应该可以正常工作。如果将管道移除到foreach-object,你会得到任何输出吗?您使用的是PowerShell v3吗?试一试,你得到WhatIf消息吗?

dir E:\Music -File -Exclude *.mp3 -Recurse | del -WhatIf

答案 2 :(得分:1)

参见以下命令的示例4

 get-help remove-item -Examples

“因为此cmdlet中的Recurse参数有问题...”

是我的猜测。

相关问题