簡體   English   中英

Powershell remove-item無法正常工作

[英]Powershell remove-item not working

為什么是

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

不工作? 我測試了我能想到的所有可能性,但仍然無法正常工作。

提前致謝。

我有同樣的問題,我使用以下內容來解決它:

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

該命令看起來沒問題,應該可行。 如果將管道移除到foreach-object,你會得到任何輸出嗎? 您使用的是PowerShell v3嗎? 嘗試一下,你得到WhatIf消息嗎?

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

請參閱以下命令中的示例4

 get-help remove-item -Examples

“因為此cmdlet中的Recurse參數有問題...”

是我的猜測。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM