Issue with execution of Octopus PS script

Using Octopus to create a website and am getting the attached error with the Octopus.Features.IISWebSite_BeforePostDeploy.ps1 script when it’s trying to create the site.

Error message is: Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.

I am also having same exact issue, please keep me posted about the solution. Thanks


Can you log in to the remote machine that is experiencing the problem, and run the following PowerShell script, and tell me what happens?

Import-Module WebAdministration

# Create a site with this name - you should delete it afterwards
$webSiteName = "Bar"

pushd IIS:\
$sitePath = ("IIS:\Sites\" + $webSiteName)
$site = Get-Item $sitePath -ErrorAction SilentlyContinue
if (!$site) { 
    Write-Host "Site `"$WebSiteName`" does not exist, creating..." 
    $id = (dir iis:\sites | foreach {$} | sort -Descending | select -first 1) + 1
    new-item $sitePath -bindings @{protocol="http";bindingInformation=""} -id $id -physicalPath $webRoot

Note that you’ll have to run it from an elevated PowerShell session.

The problem seems to be that due to configuration on the machine, for some reason the call to New-Item is resulting in PowerShell prompting for more information, which it can’t do. I need to know what it is prompting for.



I ran the script and it created the site, but I also got error on the first Import statement. Here is the result of script execution:

`PS C:\Users\naveedm> Import-Module WebAdministration
Import-Module : File C:\windows\system32\WindowsPowerShell\v1.0\Modules\WebAdministration\WebAdministrationAliases.ps1
cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for m
ore details.
At line:1 char:14

  • Import-Module <<<< WebAdministration
    • CategoryInfo : NotSpecified: (:slight_smile: [Import-Module], PSSecurityException
    • FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.ImportModuleCommand

PS C:\Users\naveedm> # Create a site with this name - you should delete it afterwards
PS C:\Users\naveedm> $webSiteName = "Bar"
PS C:\Users\naveedm> pushd IIS:
PS IIS:> $sitePath = (“IIS:\Sites” + $webSiteName)
PS IIS:> $site = Get-Item $sitePath -ErrorAction SilentlyContinue
PS IIS:> if (!$site) {

Write-Host "Site `"$WebSiteName`" does not exist, creating..."
$id = (dir iis:\sites | foreach {$} | sort -Descending | select -first 1) + 1
new-item $sitePath -bindings @{protocol="http";bindingInformation=""} -id $id -physicalPat

h $webRoot


Site “Bar” does not exist, creating…

Name ID State Physical Path Bindings

Bar 2 Started http`

I saved this script as Ocottest.ps1 and ran it from an elevated PS windows and here are the results:


Site does in fact now exist.

Note: I deleted the bar site and tried just copy-paste into the PowerShell window and it paused at this point:

After pressing Enter, it completed the site creation:

From: Mein, Robert - IST contractor
Sent: Tuesday, March 11, 2014 9:06 AM
To: ‘Paul Stovell’
Subject: RE: Issue with execution of Octopus PS script [Problems #16549]

I saved this script as Ocottest.ps1 and ran it from an elevated PS windows and here are the results:


Site does in fact now exist.

Hi Robert,

I have a hunch that your server might have a $ConfirmPreference that is higher than we expect. You can read more about this here:

It’s possible that your user account has a different preference to the value used by the account that Tentacle runs under.

Is your Tentacle service configured to run under a custom user account?

Could you create a script step that looks like this, and add it as a step to your project in Octopus so that it gets run on the remote machine, and let me know what it says?

Write-Host $ConfirmPreference




The tentacle service is running as “Local System”.


Hi Robert,

On your Tentacle, could you try replacing the contents of this file:

C:\Program Files\Octopus Deploy\Tentacle\Scripts\Octopus.Features.IISWebSite_BeforePostDeploy.ps1

With the contents here:

And tell me how that goes?


I followed your instructions and saw no difference. I then noticed the location where the scripts was actually being run (C:\Octopus2\Applications.Tentacle\Octopus.Tentacle\\Scripts) was different than the location you listed so I copied the new script there and deployed a release and got the following error:


Looks like a syntax error with an errant “-“. I removed that and redeployed. Received a new error:


Hi Robert,

Thanks for this. I’ve updated the script - could you try this version?


Updated the PS script. Got the same error:


I’ve been invesitgating this via another ticket and have a bit of a thory; if you want to cut straight to the chase here’s an updated script:

Details - it would seem that -Confirm is handled by PowerShell, while -Force (added in the version above) is passed to the underlying provider (e.g. the WebAdministration implementation).

A badly-behaved module that ignores -NonInteractive might still respect -Force.

I think we’re hitting this because the target of the command does already exist but isn’t being retrieved, and we use -ErrorAction “SilentlyContinue” to steamroll over this.

Apologies if this is yet another dead end, but seems like it is worth a shot.

Hope this helps,

Thanks for the input Nicholas. I updated the appropriate script and had no better luck. Still getting the same error:


Thanks for the update Robert. At this stage I’m pretty stumped about why it would be prompting. We’re going to make a change in the next release to allow you to disable the NonInteractive flag and hopefully see why it is prompting:

I’m sorry I don’t have any other solution at present, we should have the new release out in a week or so.


I am having the exact same problem. I will look into this thread in detail but just thought I’d share my setup: My project that has been successfully deployed many times on many machines. Today I was going to install the project on a new machine. Tentacle healtch seems fine, latest version of Calamari, but deploy fails with the exact same error message as on the top of this page.

Hi Emil,

Thanks for reaching out. The error at the top of the thread makes reference to our old IIS deploy steps. In 3.4.7 we introduced our latest version of them, which is basically a complete overhaul:

If you are not using these new steps, I recommend you to give them a try and see if you still get this error using them.