ERROR: a Powershell scheduled script with a Boolean argument do not run

The error you receive running the script with “powershell -file” is:

Cannot process argument transformation on parameter ‘Interactive’. Cannot convert value “System.String” to type “System.Boolean”, parameters of this type only accept booleans or numbers, use $true, $false, 1 or 0 instead.

It appears that powershell.exe does not fully evaluate script arguments when the -File parameter is used. In particular, the $false argument is being treated as a string value.

Instead of using -File you could try -Command, which will evaluate the call as script:

powershell.exe -NoProfile -Command .\Script.ps1 -Site Test -Interactive $false

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s