This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

ERROR: Invoke-SwisVerb : Verb Orion.AlertSuppression.SuppressAlerts cannot unpackage parameter 0 of type System.String

Trying to create a function that will mute a node on the fly and I am getting the following error:

Invoke-SwInvoke-SwisVerb : A positional parameter cannot be found that accepts argument 'System.Object[]'.
At line:41 char:9
+         Invoke-SwisVerb -SwisConnection $Swis -EntityName $Entity -Ve ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-SwisVerb], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,SwisPowerShell.InvokeSwisVerb

Here is my code:

function Mute-SWNode {
	[CmdletBinding()]
	param(
		[Parameter()]
		[String] $MuteNode
	)

	#Create Connection to SWIS data
	$Creds = Get-Credential -UserName "Username" -Message "Enter Admin Credentials"
	$SwisCreds = $Creds
	$SwisHost = "OrionServer"
	$Swis = Connect-Swis -Hostname $SwisHost -Credential $SwisCreds
	$Entity = 'Orion.AlertSuppression'

	#Isolate Node Name
	$GetNodeCaption =  @"
SELECT DISTINCT [Nodes].Caption
FROM Orion.AlertObjects
JOIN Orion.Nodes ON Nodes.Caption = AlertObjects.RelatedNodeCaption
WHERE AlertObjects.RelatedNodeCaption = '$($MuteNode)' AND AlertObjects.EntityType = 'Orion.Nodes'
"@

	$NodeCaption = Get-SwisData -SwisConnection $Swis -Query $GetNodeCaption
	$NodeCaption = $NodeCaption | ForEach-Object { [string]$_ }

	#Isolate Alert Uri
	$GetNodeUri = @"
SELECT DISTINCT
[Nodes].AlertObjects.EntityUri
FROM Orion.AlertObjects
JOIN Orion.Nodes ON Nodes.Caption = AlertObjects.RelatedNodeCaption
WHERE AlertObjects.RelatedNodeCaption = '$($MuteNode)'"
"@

 
	$NodeUri = Get-SwisData -SwisConnection $swis -Query $GetNodeUri
	$NodeUri = $NodeUri | ForEach-Object { [string]$_ }

 
	if ($NodeCaption -eq $MuteNode) {
		Invoke-SwisVerb -SwisConnection $Swis -EntityName $Entity -Verb SuppressAlerts -Arguments $NodeUri @($NodeUri,[DateTime]::UtcNow) | Out-Null
		#Write-host $Swis
	}
}

Parents Reply Children
No Data