Skip to content

Commit

Permalink
Add Get-SCSMIRComment
Browse files Browse the repository at this point in the history
  • Loading branch information
lazywinadmin committed Mar 15, 2015
1 parent 8a66600 commit 4fb6427
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions SCSM-IR-Get-SCSMIRComment/Get-SCSMIRComment.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function Get-SCSMIRComment
{
<#
.SYNOPSIS
Function to retrieve all the comment of a Incident Request
.DESCRIPTION
Function to retrieve all the comment of a Incident Request
.PARAMETER Incident
Specifies the Incident Request Object.
.EXAMPLE
PS C:\> Get-SCSMIRComment -Incident (get-scsmincident -ID 'IR55444')
.NOTES
Francois-Xavier Cat
www.lazywinadmin.com
@lazywinadm
#>
[CmdletBinding()]
PARAM
(
[System.WorkItem.Incident[]]$Incident
)
PROCESS
{
FOREACH ($IR in $Incident)
{
TRY
{
# Retrieve Comments
$FilteredIncidents = $IR.AppliesToTroubleTicket | Where-Object {
$_.ClassName -eq "System.WorkItem.TroubleTicket.UserCommentLog" -OR $_.ClassName -eq "System.WorkItem.TroubleTicket.AnalystCommentLog"
}

IF ($FilteredIncidents.count -gt 0)
{
FOREACH ($Comment in $FilteredIncidents)
{
$Properties = @{
IncidentID = $IR.ID
EnteredDate = $Comment.EnteredDate
EnteredBy = $Comment.EnteredBy
Comment = $Comment.Comment
ClassName = $Comment.ClassName
IsPrivate = $Comment.IsPrivate
}

New-Object -TypeName PSObject -Property $Properties
} # FOREACH
} #IF Incident found
}
CATCH
{
$Error[0]
}
} #FOREACH ($IR in $Incident)

} #Process
} #Function

0 comments on commit 4fb6427

Please sign in to comment.