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

Spa*_*key 7 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.
Run Code Online (Sandbox Code Playgroud)

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

Dis*_*ame 9

Remove-Item -path 'C:\agent\_work\2\a\Foo\_PublishedWebsites\Foo\sourcejs\*' -Recurse -Force -EA SilentlyContinue -Verbose
Run Code Online (Sandbox Code Playgroud)

  • 不管你信不信,最重要的一点是“-Recurse”。 (6认同)
  • 请解释为什么这有效。仅代码答案不应有 21 票赞成。 (4认同)