Quantcast
Channel: SCSM PowerShell Cmdlets
Viewing all articles
Browse latest Browse all 306

New Post: Adding comments to SRs

$
0
0
Thanks, Jim! You gave me some hints...
Sorry to hear you're out of the SM team... :(

I'll share my findings with the rest in case you're looking for this:
function Add-SRComment {
    param (
            [parameter(Mandatory=$true,Position=0)][Alias('SRObject')]$pSRObject,
            [parameter(Mandatory=$true,Position=1)][Alias('Comment')][String]$pComment,
            [parameter(Mandatory=$true,Position=2)][Alias('EnteredBy')][String]$pEnteredBy
          )
    $NewGUID = ([guid]::NewGuid()).ToString()
    $Projection = @{__CLASS = "System.WorkItem.ServiceRequest";
                    __SEED = $pSRObject;
                    AnalystCommentLog = @{__CLASS = "System.WorkItem.TroubleTicket.AnalystCommentLog";
                                          __OBJECT = @{Id = $NewGUID;
                                                       DisplayName = $NewGUID;
                                                       Comment = $pComment;
                                                       EnteredBy  = $pEnteredBy;
                                                       EnteredDate = (Get-Date).ToUniversalTime();
                                                       IsPrivate = $false
                                                      }
                                         }
                   }
    New-SCSMObjectProjection -Type "System.WorkItem.ServiceRequestProjection" -Projection $Projection
}


Add-SRComment -SRObject $SR -Comment "This is a test" -EnteredBy "Doe, John"

Viewing all articles
Browse latest Browse all 306

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>