0

Invoke-SQLCMD cmdlet does not work when executed through powershell script (.ps1)

Following error is logged:

[error]Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available. [error]Process completed with exit code 0 and had 1 error(s) written to the error stream.

When executed through interactive window it asks for user confirmation.

Is there a work around to pass the default value Yes when executed through scripts?

Nurjan
  • 5,889
  • 5
  • 34
  • 54
Santhosh
  • 671
  • 12
  • 36

1 Answers1

0

Install 'Windows PowerShell Extensions for SQL Server' from the Microsoft® SQL Server® 2008 R2 Feature Pack page (it's about halfway down the page). Make sure you pick the correct flavor for your instance (32 or 64 bit). Run these two commands before calling invoke-sqlcmd in your script: Add-PSSnapin SqlServerCmdletSnapin100 Add-PSSnapin SqlServerProviderSnapin100

Vishe
  • 3,383
  • 1
  • 24
  • 23