I’m attempting to write a very simple PS script to query my SQL Agents failed job history to create a report. SQL instances are on several servers but in the same domain. After queering the filth or so server in my server list, the process appears to stall (ise output stops)
The server I’m running the script on is our CMS server and looking at the VM performance console I was expecting a spike in CPU or memory utilization, but nothing.
Can you share more of your code, particularly the loop that you’re using?
$Server is in your code example but we can’t see where it was defined.
Also, I don’t think your calculated property syntax is correct. You’ve got Exression{} instead of Expression={<yourcode>} then you have an if/else statement. I suspect this is supposed to be inside your Expression scriptblock.
If you run the following command does it say the “ServerInstance” parameter accepts strings or is it looking for a specific object?
Get-Help Get-SqlAgentJobhistory -Full
Does it say something like [[-ServerInstance] <string>] ? or is it looking for an object.
Some other things to keep in mind depending on your level of SQL knowledge:
Not every SQL instance is the servers name instances can be named whatever the DBA wants to call it. Yes by default if you do not name it it defaults to the servers name.
MSSQL can have more than one instance running on a given server so you will only be finding the “default” instance
Let us know what the HELP says about that parameter.
I was able to find the help for that command online.
The good news is it does accept string values. However, you still need to consider that not every instance will match the name of the server hostname itself.
But shouldn’t the applet call return an error and not hang-up/freeze the process?
I get nothing returned nor any information in the ‘catch’ to what happened to stall the process. The stalling is what I need to resolve, then if my syntax needs tweaking for multiple instances those corrections can be made