Quantcast
Channel: THWACK: Popular Discussions - Orion SDK
Viewing all articles
Browse latest Browse all 3719

SDK/PowerShell - Group Creation Script Issue

$
0
0


Trying to use the following script (based on the 'Groups' example in the SDK) to add groups based on Nodes.Location and a CustomProperty !=

 

if (! (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {    Add-PSSnapin "SwisSnapin"
}
# Connect to SWIS
$hostname = "localhost"
$username = "username here"
$password = "password here" | ConvertTo-SecureString -asPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$swis = Connect-Swis -host $hostname -cred $cred
#Set the locatoin of the csv
Set-Location 'C:\Users\username here\Desktop'
# read in csv file
$importFile="./MakeGroups.csv"
$importList=IMPORT-CSV $importFile
#iterate through each entry in csv file
FOREACH($import in $importList)
{    $SiteCode = $import.Location    $members = @(  @{ Name = "$SiteCode"; Definition = "filter:/Orion.Nodes[Location='$SiteCode' AND CustomProperties.Device_Type != 'Router']" }
)
$groupId = (Invoke-SwisVerb $swis "Orion.Container" "CreateContainer" @(    # group name    "$SiteCode",    # owner, must be 'Core'    "Core",    # refresh frequency    60,    # Status rollup mode:    # 0 = Mixed status shows warning    # 1 = Show worst status    # 2 = Show best status    0,    # group description    "Group created by the PowerShell sample script.",    # polling enabled/disabled = true/false (in lowercase)    "true",    # group members    ([xml]@(       "<ArrayOfMemberDefinitionInfo xmlns='http://schemas.solarwinds.com/2008/Orion'>",       [string]($members |% {         "<MemberDefinitionInfo><Name>$($_.Name)</Name><Definition>$($_.Definition)</Definition></MemberDefinitionInfo>"         }       ),       "</ArrayOfMemberDefinitionInfo>"    )).DocumentElement  )).InnerText    
}

 

 

Keep getting this error:

 

Invoke-SwisVerb : Entity Orion.Nodes does not contain requested property A

At C:\Users\username here\Desktop\MakeGroups.ps1:32 char:14

+  $groupId = (Invoke-SwisVerb $swis "Orion.Container" "CreateContainer" @(

+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

 

 

Looking in the DB, the script is creating the group under 'Containers', but there is not an entry being created under 'ContainerMemberDefinitions'

 

All help is appreciated


Viewing all articles
Browse latest Browse all 3719

Trending Articles



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