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.

Invoke-SwisVerb : Verb Orion.APM.Application.Unmanage cannot unpackage parameter 3 of type System.Boolean

Hello! I need to create a script that will unmanage a group of application monitors when another team is scripting out upgrades.  I created the powershell script and while it works it spits out an error everytime.  It still unmanages the application using the right times.  Script is included below.  The error message (below) mentions the unmanage 3rd parameter but it is setting the monitor in an unmanage state for 1 day like I have specified.  Does anyone know what I am doing wrong?

Invoke-SwisVerb : Verb Orion.APM.Application.Unmanage cannot unpackage parameter 3 of type System.Boolean
At line:13 char:9
+ Invoke-SwisVerb -SwisConnection $SwisConnection -EntityName O ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
+ FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

$IPs = Get-Content "C:\Scripts\IPs.txt"
Import-Module -Name SwisPowerShell
$SwisConnection = Connect-Swis -Hostname $HostName -UserName $Username -Password $PWord
$nowUTC = [DateTime]::UtcNow
$laterUTC = [DateTime]::UtcNow.AddDays(1)
FOREACH($IP in $Ips){
    $AppID = (Get-SwisData $SwisConnection "SELECT A.ApplicationID FROM Orion.APM.Application A WHERE A.Node.IP_Address = '$IP' AND A.ApplicationTemplateID = 721")
    $AppStatus = (Get-SwisData $SwisConnection "SELECT A.Status FROM Orion.APM.Application A WHERE A.Node.IP_Address = '$IP' AND A.ApplicationTemplateID = 721")
    
    IF ($AppStatus -ne "9") {
        Write-Host "AppID $AppID"
        Write-Host "Status $AppStatus"
        Invoke-SwisVerb -SwisConnection $SwisConnection -EntityName Orion.APM.Application -Verb Unmanage -Arguments "AA:$AppID", $nowUTC, $laterUTC, "False"
        }}

Parents
  • Sounds like its handling "False" a bit weird. Try "0" or "$false"?

  • Yes - the "Boolean" for PowerShell is either $true or $false.  Don't use the string equivalent because it doesn't have a "translation" when coming via the Module.

  • Using $False gave me a different error:

    Invoke-SwisVerb : no viable alternative at input '<EOF>' in Where clause
    At line:13 char:9
    + Invoke-SwisVerb -SwisConnection $SwisConnection -EntityName O ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

  • Using $False gave me a different error:

    Invoke-SwisVerb : no viable alternative at input '<EOF>' in Where clause
    At line:13 char:9
    + Invoke-SwisVerb -SwisConnection $SwisConnection -EntityName O ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

  • Sounds like you might have nicked a quote or some other minor formatting thing. Not sure how a "where clause" is sneaking into line 13 as is

  • It reads as if an IP was listed, but the matching application wasn't found.

    For myself, I prefer using Muting (Suppress Alerts).  I've got a quick sample script here that shows both methods here: Unmanage or Suppress Alerts (Applications) - Scripts - The Orion Platform

  • Weirdly enough, even though it spits out an error, it still works as it is intended.  The applications become unmanaged for the time (1 day) specified.  I'll play with it using your example to see if it works better.  

  • Invoke-SwisVerb -SwisConnection $SwisConnection -EntityName Orion.APM.Application -Verb Unmanage -Arguments "AA:$AppID", $nowUTC, $laterUTC, $false
    If the n-th IP in your listing doesn't exist as a node OR doesn't have that particular application assigned, then your query (and the returned $AppId) will be null.  Then when you try to execute the above snippet, you'll be sending "AA:", <startTime>, <endTime>, $false - which is being misinterpreted as a premature end of line (because there's no number associated with the NetObjectId.

  • Thanks, Kevin! You were 100% right.  I took the empty lines out of the text file and it works without errors after changing "False" to $false.

  • You could probably omit the blank lines in the Get-Content function by converting it to:

    # This ugly regex will bascially see if the "line" in the file matches a correct IP format
    Get-Content -Path "C:\Path\To\File.txt" | Where-Object { $_ -match '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$' }
    
    <# Example File Contents and matching
    999.999.999.999            [FAIL]
    0.0.0.0                    [FAIL]
    computername.domain.local  [FAIL]
    computername               [FAIL]
    <blank line>               [FAIL]
    192.168.21.11<blank space> [FAIL]
    <blank space>127.32.5.18   [FAIL]
    10.1.1.0                   [PASS]
    192.168.4.7                [PASS]
    127.39.11.8                [PASS]
    #>

  • Also - your best bet is to save the entire processing history to a log file of some kind and not just out to the screen with Write-Host.

    Best bet - always write scripts in such a way that you assume the stupidest thing possible is being done with anything being used as a data source.

Reply
  • Also - your best bet is to save the entire processing history to a log file of some kind and not just out to the screen with Write-Host.

    Best bet - always write scripts in such a way that you assume the stupidest thing possible is being done with anything being used as a data source.

Children
No Data