mehnihma mehnihma - 1 month ago 16
PowerShell Question

Powershell SQLCMD Mode error

I am trying to run PowerShell Invoke-Sqlcmd but I get an error:

Invoke-Sqlcmd -MaxCharLength 100000 -ServerInstance server1\darabse -InputFile \\server\query.sql

Invoke-Sqlcmd :
At line:6 char:1
+ Invoke-Sqlcmd -MaxCharLength 1000000 -ServerInstance server\database ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], ParserException
+ FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

I can run in in Management studio with SQLCMD Mode.

I have tried everything form here . Any ideas? There is no "$" within it.

I succeed to do i like this, but I am not sure this is solution?

sqlcmd -i \\server\Shared\install\file.sql



it works like this:

cmd.exe /C sqlcmd -i \\share\Shared\install_scripts\02SQL\create.sql