我正在运行以下命令:
get-childitem C:\temp\ -exclude *.svn-base,".svn" -recurse | foreach ($_) {remove-item $_.fullname}
这经常提示我这样:
Confirm
The item at C:\temp\f\a\d has children and the Recurse parameter was not specified. If you continue,
all children will be removed with the item. Are you sure you want to continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
如何将其自动设置为“A”?
尝试在-Force
上使用Remove-Item
参数。
默认为:无提示。
您可以使用-Confirm
启用它或使用-Confirm:$false
禁用它
但是,当目标时它仍然会提示:
-Recurse
参数。-Force
还需要删除隐藏和只读项目等。
把它们加起来:
Remove-Item -Recurse -Force -Confirm:$false
......应涵盖所有情景。
添加-confirm:$ false以禁止确认。
在remove-item之后添加-recurse,-force参数也有助于删除隐藏文件,例如:
gci C:\ temp \ -exclude * .svn-base,“。svn”-recurse | %{ri $ _ -force -recurse}
Remove-Item .\foldertodelete -Force -Recurse
你只需要在线后添加一个/A
。
例:
get-childitem C:\temp\ -exclude *.svn-base,".svn" -recurse | foreach ($_) {remove-item $_.fullname} /a