Reputation: 1562
I am trying to create a shell script to run a query and store the output, and I've got my script looking like this so far:
push-location;
import-module SqlPs;
Pop-Location;
$myData = invoke-sqlcmd -InputFile "C:\<path>\blah.sql" -serverinstance dbatest -database testdb;
$mydata | out-file C:\Users\<path>\shelloutput.csv;
remove-module sqlps;
It loads SqlPs fine which I can check with with Get-Module -ListAvailable
producing this
but when I do invoke-sqlcmd
it is not recognized:
Any ideas as to what else I can do?
When I add the option -Verbose
I see this error saying that some files are already present. Is this error preventing me from loading the module? When I do Get-Module
it doesn't list the SQLPS module.
Loading the 32 bit version gives me fewer errors but still errors loading files...now only 2 files are missing as opposed to 5 earlier
Upvotes: 2
Views: 739
Reputation: 65
I found on my system that I had in the path several sql bin references to 32 bit (Program Files (x86)) paths ahead of the 64 bit paths. I moved all the 32 bit paths below the 64 bit paths and it cleared up the issues.
Upvotes: 1