Nothing fancy here. I just need a basic query that will find (fixed disk) volumes across all nodes that have the word "merged" in their path name, and delete them.
SWQL is a read-only interface, so it can get you the list, but then you'll need to call a verb to delete the things. In PowerShell, you'd use the Remove-SwisObject function, but other languages are also supported.
Remove-SwisObject
Depending on what exactly you mean for your filter, this will probably work.
SELECT [Volumes].DisplayName AS [Volume] , [Volumes].Node.DisplayName AS [Node] , [Volumes].Uri AS [VolumeUri]FROM Orion.Volumes AS [Volumes]WHERE [Volumes].Type = 'Fixed Disk' AND ( [Volumes].DisplayName LIKE '%merged%' OR [Volumes].DeviceId LIKE '%merged%' )
Thank you! The output is exactly what I was looking for. Now I'm having an issue with my Powershell to remove. See the error below and my PS script. The $uris output is correct. A quick search shows this may be related to not using swis v3? Could you advise on how to properly state my endpoint if this is the case?
Import-Module -Name SwisPowerShell$SwisParams = @{ Hostname = ''; Username = ''; Password = '';}$swis = Connect-Swis @SwisParams$uris = Get-SwisData $swis "SELECT [Volumes].DisplayName AS [Volume] , [Volumes].Node.DisplayName AS [Node] , [Volumes].Uri AS [VolumeUri]FROM Orion.Volumes AS [Volumes]WHERE [Volumes].Type = 'Fixed Disk' AND ( [Volumes].DisplayName LIKE '%merged%' OR [Volumes].DeviceId LIKE '%merged%' )"#$uris | Remove-SwisObject $swis#$uris | Out-GridView -Title "Merged Volumes"
I'm not sure that Remove-SwisObject is built to allow pipeline. I've honestly never tried it. I'd do it as a ForEach or ForEach-Object to rule that out. Are you getting anything if you remove the comment from the final line?
ForEach
ForEach-Object
Yes, the Out-Gridview works fine and displays all of the volumes I'd expect to see from the query. I have another script where Remove-SwisObject works fine with pipeline so I'm a bit stumped on why this particular script doesn't work.
Is there another powershell function I could use to delete volumes in bulk?