强制不在非交互模式下工作

时间:2016-07-12 16:34:19

标签: powershell

Deleting folder 'C:\agent\_work\2\a\Foo\_PublishedWebsites\Foo\sourcejs'

Remove-Item : Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
At C:\agent\_work\2\s\Build\Deployment\PrepareWebsites.ps1:29 char:2
+ Remove-Item -Path $source -Force -Confirm:$false | Where { $_.PSIsContainer }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Remove-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RemoveItemCommand

Process completed with exit code 1 and had 1 error(s) written to the error stream.

我尝试添加-Force和-Confirm:$ false但我仍然遇到此错误。使用TFS 2015构建。有人有任何想法吗?

1 个答案:

答案 0 :(得分:7)

Remove-Item -path 'C:\agent\_work\2\a\Foo\_PublishedWebsites\Foo\sourcejs\*' -Recurse -Force -EA SilentlyContinue -Verbose