Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

unable to get the output of Invoke-sqlcmd while using in scriptblock

$
0
0

I am using a script block to run a query and perform an action depending upon the results of it. Invoke-sqlcmd doesn't seem to be working inside script block. It produces blank output, whereas i put in the same command outside script block, i get the desired output.

Invoke-sqlcmd -query "Select top 1 Message from dbo.xxx order by Timestamp desc" -serverinstance "xxx/sss"

This produces the output as "Data Uploaded;Success:True" when used outside the script block. When i use within a script block, no output. i tried to use -OutVariable and get the result to a variable but no go. 

The other functions such as moving and copying files within script block works. Its only this query that doesn't work.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>