Comments
3 comments
-
Hi Benethor, how about something like this?
Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145' $environmentName = $null # replace with environment name string if desired $machineName = 'myMachineName' $instancesOnMachine = Get-SqlCloneSqlServerInstance -MachineName $machineName | where {$_.Environment -eq $environmentName} foreach ($instance in $instancesOnMachine) { $clonesToDelete = Get-SqlClone -Location $instance foreach ($clone in $clonesToDelete) { Remove-SqlClone $clone | Wait-SqlCloneOperation } }
This will find all SQL Server instances on a named machine, then find all clones based on those instances, and delete them. -
Nice! Does exactly what I need.
Thanks a lot! -
No problem - bear in mind I've spotted a bug in the case where $environmentName is null (intended to specify 'no environment'), in that if there are machines of the given name with an environment set, it'll delete clones from them as well. I'll fix that today and update the post.
Edit: updated!
Add comment
Please sign in to leave a comment.
in a similar fashion to the "Remove All Clone for an Image", can I remove all clones for a machine? I'm not certain that using Get-SqlClone how to filter all clones for a machine name.
Thank you for your help and best regards to the dev team!
(Remove All Clone for an Image)
https://documentation.red-gate.com/display/CLONE2/Remove+all+clones+for+an+image