-1

I'm running a PowerShell script during a TFS 2015-based deployment. It won't run because PS thinks it needs user interaction, but, when I copy-and-paste the command and arguments into the PS console and call it directly, it works exactly as expected (with no user input).

Any suggestions? Thanks.

This is the top. I can't include more due to licensing reasons:

[CmdletBinding()]
param(
    [ValidateNotNullOrEmpty()]
    [String]
    $LocalDataPath, # .

    [ValidateNotNullOrEmpty()]
    [String]
    $ApiEndpointUrlPrefix, # http://hostname/ReportServer

    [ValidateNotNullOrEmpty()]
    [String]
    $DataSourceUrlRelPath = "Data Sources",

    [ValidateNotNullOrEmpty()]
    [String]
    $DatasetUrlRelPath = "Datasets",

    [ValidateNotNullOrEmpty()]
    [String]
    $ReportUrlRelPath = "Reports",

    [ValidateNotNullOrEmpty()]
    [String]
    $RootUrlAbsPath = "/Root"
)
Dustin Oprea
  • 560
  • 2
  • 8
  • 19

1 Answers1

2

That error is caused by some cmdlet or command in your script (showing the parameters is a red herring).

Look for Write-Host, Remove-Item et similia.

You can try executing your script passing the -NonInteractive flag to the Powershell interpreter or experiment different values for the $ConfirmPreference variable (e.g. None).

Giulio Vian
  • 508
  • 2
  • 10
  • @GuilioVian Yes, I have many Write-Host calls. How does using Write-Host for output translate to PowerShell claiming that it needs user-input? When I run the exact same command by hand it runs without prompting the user for anything but when I run it as part of the deployment it terminates *immediately* with that error. – Dustin Oprea Jul 22 '16 at 11:50
  • 1
    Powershell is an interpreter + a host app (e.g. console, ISE, your own), Write-Host cmdlet requires some host app interfaces. – Giulio Vian Jul 22 '16 at 12:58
  • That was *exactly* the issue. The merely presence of Write-Host caused console interpreter to demand TTY access. – Dustin Oprea Jul 22 '16 at 17:39