Public/Remove-SwNodeVolume.ps1
Function Remove-SwNodeVolume { <# .SYNOPSIS Remove volume from specific node. .DESCRIPTION This function can remove some volumes from selected node. Right now these volumes are supported: 1- Floppy 2- CD/DVD 3- RAM 4- Virtual Memory Note: Node Id of target machine is required, you can execute "Get-Node" command to find node Id. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='High')] Param ( [Parameter(Mandatory = $true)] [SolarWinds.InformationService.Contract2.InfoServiceProxy]$InfoServiceProxy, [Parameter(Mandatory = $true)] [int]$NodeId, [Parameter(Mandatory = $true)] [ValidateSet('Floppy', 'CD/DVD','RAM','VirtualMemory')] [string]$Type ) Begin{ if ($Type -eq "Floppy"){ $volumeType = "Floppy Disk" } elseif($Type -eq "CD/DVD"){ $volumeType = "Compact Disk" } elseif($Type -eq "RAM"){ $volumeType = "RAM" } elseif($Type -eq "VirtualMemory"){ $volumeType = "Virtual Memory" } } Process{ Write-Verbose -Message ("{0} -> Geting all node's volumes ..." -F $node.Name) $volumes = Get-SWVolume -InfoServiceProxy $InfoServiceProxy -NodeId $NodeId | Where-Object -Property VolumeType -eq $volumeType foreach($vol in $volumes){ #Remove related volumes if($PSCmdlet.ShouldProcess( "Verbose Description !", "Remove Resource " + "Caption")){ Write-Verbose -Message ("{0} -> Volume '{1}' is removed." -F $node.Name,$vol.Name) Remove-SwisObject -SwisConnection $InfoServiceProxy -Uri $vol.Uri } } } End{ } } |