Here-strings @""@

I have a few variables that contains a bunch of sql statements (several lines deep) that are wrapped in a here-string, these are executed like: invoke-Sqlcmd2 -Query $SQLQuery1 -ServerInstance ‘servername,4433’

What I have noticed is that when ud loads them for the 1st time, I see the following in the output ud log, and I receive a " Exception calling “Invoke” with “0” argument(s): “Exception calling “Invoke” with “0” argument(s): “Cannot index into a null array.””" on my card where I’m trying to display the data, When I re-run the dashboard the 2nd time, the variable appears to get loaded, I dont see the error in the log and the component displays the data.

Has anyone ran into this? or are doing it differently? not sure if this really belongs in the git issues page.

Error Log

20:53:42 ExecutionService Error executing endpoint script. Cannot bind argument to parameter ‘Query’ because it is an empty string.

at <ScriptBlock>, <No file>: line 3

20:53:42 ExecutionService Error executing endpoint script. Cannot index into a null array.

at <ScriptBlock>, <No file>: line 5

20:53:42 ExecutionService Error executing endpoint script. Cannot index into a null array.

Could you give a snippet of code that you are trying to use? It seem like that should just work if the here strings are static but if you are using something like $Session or $Cache variables that aren’t populated yet it would cause that.

I’m trying to develop a dashboard for SQL Server. Would you consider providing me a copy of yours to take a look at? Or at least and example of how you coded the invoke-sqlcmd part?
Thanks

Hi @dennisa95 I put an sql dashboard on github here:
https://github.com/psDevUK/psUniversalDashboard?files=1
Hope this helps

1 Like