Public/Get-SwVolume.ps1

Function Get-SwVolume {
    <#
        .SYNOPSIS
        Return Volumes from solarwinds database
 
        .DESCRIPTION
        This function gets an InfoServiceProxy and a name or ID related to a Node. after that can retrive information about node's volumes.
        Note: Name and Id could not be used at the same time.
        If you use name, function will find all Node which can match this name partially.
        If you do not define name or Id, Function will return all volumes in database
    #>

    [CmdletBinding()]
    [OutputType([System.String])]
    Param (
        [Parameter(Mandatory = $true)]
        [SolarWinds.InformationService.Contract2.InfoServiceProxy]$InfoServiceProxy,

        [string]$NodeName,

        [int]$NodeId
    )

    Begin{

        if ($PSBoundParameters.ContainsKey('NodeId') -and $PSBoundParameters.ContainsKey('NodeName') ){
            Write-Error("Both NodeName and NodeId can not be used at the same time ")
            return
        }

        $query = "SELECT NodeId,VolumeId,VolumeIndex,Caption,VolumeType,Uri,`
                    VolumePercentUsed,VolumeSize,DiskQueueLength,DeviceId,Status, `
                    LastSync FROM Orion.Volumes"


        if ($PSBoundParameters.ContainsKey('NodeName')){
            $query += " WHERE FullName Like '%$NodeName%'"
        }
        elseif ($PSBoundParameters.ContainsKey('NodeId')) {
            $id = $NodeId.ToString()
            $query += " WHERE NodeId = $id"
        }

        [Parmis.SolarWinds.Volume[]]$output = @()
    }
    Process{
        Write-Verbose -Message "Fetching query from server ..."
        $result = Get-SwisData -SwisConnection $InfoServiceProxy -Query $query
        if($null -eq $result){
            return $null
        }
        elseif ($result.length -eq 1) {
            return ConvertTo-SwVolume -Object $result
        }
        else{
            [Parmis.SolarWinds.Volume[]]$output = @()
            foreach ($item in $result ){
                $output += ConvertTo-SwVolume -Object $item
            }
            return($output)
        }
    }
    End{
    }
}