I'm new to scripting so, has anyone written a script to delete a node using the SDK? I see the post for deleting a volume - is it the same or is Java the only method as described in SDK guide?
Thanks, Denise
What language are you working in? PowerShell?
PowerShell & VB.
In PowerShell, it would look like this:
$uri = "swis://tdanner-dev.swdev.local/Orion/Orion.Nodes/NodeID=1"
Remove-SwisObject $swis $uri
To find out the Uri for a node, just query for it:
$uri = Get-SwisData $swis "SELECT TOP 1 Uri FROM Orion.Nodes WHERE [your criteria here]"
I'll give it a try. I saw your similar post so will f/u when accomplished. Thanks much.
My apologies that I didn’t fully describe what I’m trying to do. This is my scenario:
1. I’ll receive a ‘delete’ file that contains a Store_ID that needs deleted (store has been closed, etc), the store_ID is a Custom Property
2. This script --- will pick up the file with the Store_ID’s, query the store for the NodeID , and then delete the NodeID from Orion.Nodes
I’ll be setting up a Windows Scheduled task to run this file (if data exists) at least every 2 hours.
That sounds fairly straightforward. You just need to query for the Store_ID value where I put [your criteria here].
$storeId = [read the value from the file]
$uri = Get-SwisData $swis "SELECT TOP 1 Uri FROM Orion.Nodes WHERE Nodes.CustomProperties.Store_ID=@storeid" @{storeid=$storeId}
If you expect more than one node to have the same store id, remote the "TOP 1" from the query and loop over the set deleting them all, like this:
$uris = Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE Nodes.CustomProperties.Store_ID=@storeid" @{storeid=$storeId}
$uris |% { Remove-SwisObject $swis $_ }
Update - finish writing the message. I accidentally posted this before it was done.