Public/Get-JiraIssueComment.ps1
function Get-JiraIssueComment { # .ExternalHelp ..\JiraPS-help.xml [CmdletBinding()] param( [Parameter( Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName )] [ValidateNotNullOrEmpty()] [ValidateScript( { if (("JiraPS.Issue" -notin $_.PSObject.TypeNames) -and (($_ -isnot [String]))) { $exception = ([System.ArgumentException]"Invalid Type for Parameter") #fix code highlighting] $errorId = 'ParameterType.NotJiraIssue' $errorCategory = 'InvalidArgument' $errorTarget = $_ $errorItem = New-Object -TypeName System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $errorTarget $errorItem.ErrorDetails = "Wrong object type provided for Issue. Expected [JiraPS.Issue] or [String], but was $($_.GetType().Name)" $PSCmdlet.ThrowTerminatingError($errorItem) <# #ToDo:CustomClass Once we have custom classes, this check can be done with Type declaration #> } else { return $true } } )] [Alias('Key')] [Object] $Issue, [Parameter()] [System.Management.Automation.PSCredential] [System.Management.Automation.Credential()] $Credential = [System.Management.Automation.PSCredential]::Empty ) begin { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" } process { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)" Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)" # Find the proper object for the Issue $issueObj = Resolve-JiraIssueObject -InputObject $Issue -Credential $Credential $parameter = @{ URI = "{0}/comment" -f $issueObj.RestURL Method = "GET" GetParameter = @{ maxResults = $PageSize } OutputType = "JiraComment" Paging = $true Credential = $Credential } Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter" Invoke-JiraMethod @parameter } end { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" } } |