Have sorted this now. If anyone is interested below is the code I wrote to get the comments and extract them with some additional data into a CSV like file.
You need to change the classes and filter criteria of course if you want to re-use this script. AppliesTotroubleTicket is basically the attribute which stores the action log + comments so that's what you need to query via PowerShell.
Import-Module SMlets -CMDlet get-scsmclass,get-scsmobject,get-scsmincident $AllComments = "" $IncidentDefInfos = "" $Incident = "" $Comment = "" $IncidentsID = "" $AllCommentsResults = "" $incidentextension = get-scsmclass -name ClassExtension_4b8fb113_d448_4757_8a3c_28b7e37e5111; $IncidentsID = get-scsmobject -class $incidentextension | where {$_.BusinessApplication -ne $NULL -AND $_.Status -ne "Resolved"} | select ID foreach ($Incident in $IncidentsID) { $IncidentDefInfos = get-scsmincident -ID $Incident.ID $FilteredIncidents = $IncidentDefInfos.AppliesToTroubleTicket | where {$_.ClassName -eq "System.WorkItem.TroubleTicket.UserCommentLog" -OR $_.ClassName -eq "System.WorkItem.TroubleTicket.AnalystCommentLog"} if ($FilteredIncidents.count -gt 0) { foreach ($Comment in $FilteredIncidents) { $UserComment = "" $AnalystComment = "" $ClassName = "" $ClassName = $Comment | select ClassName Switch($ClassName.ClassName) { "System.WorkItem.TroubleTicket.UserCommentLog" {$UserComment = $Comment | select EnteredDate, EnteredBy, Comment} "System.WorkItem.TroubleTicket.AnalystCommentLog" {$AnalystComment = $Comment | select EnteredDate, EnteredBy, Comment, IsPrivate} } $IncidentComments = $Incident.ID + '","' + $UserComment.EnteredDate + '","' + $UserComment.EnteredBy + '","' + $UserComment.Comment + '","' + $AnalystComment.EnteredDate + '","' + $AnalystComment.EnteredBy + '","' + $AnalystComment.Comment + '",' + $AnalystComment.IsPrivate + "`r`n" $AllIncidentComments += $IncidentComments } } } write-host $AllIncidentComments Out-File -InputObject $AllIncidentComments -FilePath C:\Software\AllComments.csv Remove-Module SMlets
PS: Can anyone point me out how to use the -Filter switch correctly if you need to filter on two attributes? I'd like to get rid of the 'where' filtering to optimize the script performance.
Cheers
Alex