Sorry, I'm new to Powershell so I'm obviously missing something fairly fundamental but I can't seem to figure this out.
I've got a powershell script calling a SQL script. I can get the script to run but I would also like to store the output in a log file.
This is my powershell script
Add-PSSnapin SqlServerCmdletSnapin100
Add-PSSnapin SqlServerProviderSnapin100
Invoke-Sqlcmd -inputfile "testscript.sql" -serverinstance '.\sql2008' | Out-file -filepath "testlog.txt"
And this is my testscript.sql
PRINT 'HELLO WORLD'
At the moment, it creates the testlog.txt file but it is blank.
What am I doing wrong?