I'm running a PowerShell script as one of the post-build steps in TeamCity and at one point I'm trying to create an empty file as a place-holder for a later step. The code I started with was:
New-Item $MyPathAndFileName -Force
This worked fine on my machine in the ISE. However executing it in TeamCity causes the whole build step (and therefore the build configuration) to fail with a build log entry of:
Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
I've then appended to my code to end up at the following:
if((Test-Path $MyPathAndFileName) -ne 0)
{Remove-Item $MyPathAndFileName -Force}
New-Item $$MyPathAndFileName -Force -Confirm:$false -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -InformationAction SilentlyContinue
It's always the New-Item line that fails.
My question is can I either
a) get PowerShell to write out what the prompt it is trying to display so I can fault-find what is wrong?, or
b) create the new item without a prompt?