This project is read-only.

PowerShell script - StatusHalted

Topics: Developer Forum, User Forum
Dec 15, 2008 at 4:38 PM
I'm trying to run the following script, but getting an StatusHalted error. PolyMon doesn't provide any additional info and I've searched the code for this string, but didn't find anything.

Any idea what I'm doing wrong?




= @(c:\tools\scripts\Check-EmailDNSRecords.ps1 -compareDNS -failuresOnly -name Pickering)






= $result.count





= ($result | format-list | out-string).trim()





.Add("EmailDNSRecords-Bulk Errors",$errors)





($errors -gt 5) {




$status.StatusID = 3 # 3=Fail




$status.StatusText = "There are [$errors] errors. `n-------------------------- `n$string "






($errors -gt 0) {




$status.StatusID = 2 # 2=Warning




$status.StatusText = "There are [$errors] errors. `n-------------------------- `n$string "










$status.StatusID = 1 # 1=OK




$status.StatusText = "There are [$errors] errors."



Dec 15, 2008 at 11:35 PM

The wrapper script does not appear to have any errors that might cause that.  There is one problem though with the script itself.  By coercing the results into an array, your $result.count will always be at least 1. 

The only thing I can think of is that there is an error being thrown in your Check-EmailDNSRecord script that is finding it's way out.  In the PowerShell monitor, if there is an error thrown, it reports the inner exception in the status message. 

Just to see if it is the script, could you run the Check-EmailDNSRecord script outside of PolyMon, and use export-clixml to export them to an xml file.  Then in your monitor, use Import-Clixml to bring the result set into your $result variable. 

Another question just popped into my mind... have you run the monitor manually, either via the Test Monitor or via the play icon on any of the status screens?  If so, do you have the same result?

Dec 17, 2008 at 7:34 PM
(Apparently the 'Reply to email' functionality of codeplex isn't working as I replied yesterday morning but my reply isn't here)

Hi Steve,


Digging further, the same problem was exposed in PowerGUI as well. I tracked it down to my Profile.ps1 file which was returning the StatusHalted error.


I removed the offending line in the profile and PowerGUI (x86) is happy, it can run the same script w/o errors. So can PowerShell console and so can PowerShellPlus. However, PolyMon is still returning the error. I’ve even restarted the PolyMon Manager and the PolyMon Executive.


Regarding running the monitor manually, the only way I’ve tried it in PolyMon so far is via Test Monitor, I haven’t enabled the rule yet.


The first time I ran the rule through Test Monitor this morning it took about 10-15 seconds and returned the error. Subsequent times – even after fixing the profile – it is returning the error almost immediately. Does PolyMon cache the results in a situation like this, or is just due to the fact that it’s not having to load PowerShell and .Net on subsequent attempts?




Dec 17, 2008 at 10:05 PM

The lag you are seeing the first time is the overhead in starting the PowerShell runtime.  You may notice this with other .NET applications, where the first time you start the application it is a bit slow, and then responds better after that.

The process hit is taken when the PowerShell runtime is first started, so any subsequent usage will be quicker.  If you are still experiencing a lag, you might want to check and see that there aren't any other snags in the Profile.ps1 scripts (There could also be a profile.ps1 in the C:\Windows\System32\v1.0\).  However, as far as I am aware, the profile scripts are not loaded into the PowerShell runspace in PolyMon.  Are parts of your script relying on features from your profile?

The StatusHalted has to be coming from within your script (especially if you saw that error running it out of PowerGUI).

If you want me to review a sanitized version of your Check-EmailDNSRecord script, I'd be happy to review it to see if that could be generating the error (steven.murawsi at 

I'll poke around and try to create that error from PolyMon also.