From 1627090ffb72762e4cc905d6b8df7bac8a60ad9c Mon Sep 17 00:00:00 2001 From: "Sean R. Williams" Date: Thu, 31 May 2018 11:06:08 -0700 Subject: [PATCH] Change parameter validation to accommodate PSv3 --- JiraPS/Public/Remove-JiraIssue.ps1 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/JiraPS/Public/Remove-JiraIssue.ps1 b/JiraPS/Public/Remove-JiraIssue.ps1 index 801d3c33..e4a86912 100644 --- a/JiraPS/Public/Remove-JiraIssue.ps1 +++ b/JiraPS/Public/Remove-JiraIssue.ps1 @@ -13,12 +13,11 @@ function Remove-JiraIssue { [ValidateScript( { if (("JiraPS.Issue" -notin $_.PSObject.TypeNames) -and (($_ -isnot [String]))) { - $errorItem = [System.Management.Automation.ErrorRecord]::new( - ([System.ArgumentException]"Invalid Type for Parameter"), - 'ParameterType.NotJiraIssue', - [System.Management.Automation.ErrorCategory]::InvalidArgument, - $_ - ) + $exception = ([System.ArgumentException]"Invalid Type for Parameter") #fix code highlighting] + $errorId = 'ParameterType.NotJiraIssue' + $errorCategory = 'InvalidArgument' + $errorTarget = $_ + $errorItem = New-Object -TypeName "System.Management.Automation.ErrorRecord" -ArgumentList $exception,$errorId,$errorCategory,$errorTarget $errorItem.ErrorDetails = "Wrong object type provided for Issue. Expected [JiraPS.Issue] or [String], but was $($_.GetType().Name)" $PSCmdlet.ThrowTerminatingError($errorItem) <#