OpsMgr 2007 Powershell one-liner to get information on failed agent installations
Ever tried mass-installing a lot of agents from console? If yes, then you probably miss some feedback information. Once you close the running task window you loose the information. The information is kept, sadly enough in SUCCEEDED Task status - browsing through that to find failed installations in UI is hard (the failed info is kept in Task output not task status, so no easy filtering here). To get it by Powershell you can use something like:
To HTML:
get-taskresult | where {$_.Output -notlike "*<ErrorCode>0</ErrorCode>*" -and $_.Output -like "*MOM.MOMAgentManagementData*"} | ConvertTo-Html | set-content "D:\Scripts\GetTaskResult\FailedTasks.htm"
To CSV:
get-taskresult | where {$_.Output -notlike "*<ErrorCode>0</ErrorCode>*" -and $_.Output -like "*MOM.MOMAgentManagementData*"} | export-csv "D:\Scripts\GetTaskResult\FailedTasks.csv"
You can easily extend those to do some more elaborate filtering as the Output property is XML, and Psh can parse XML well.
Thx to Bogdan, my colleague from MS Poland, for giving me some background on where we keep the data. The rest was easy.