Private/ConvertTo-SwVolume.ps1
Function ConvertTo-SwVolume{ <# .SYNOPSIS Create a powershell object from [Parmis.Solarwinds.Volume] class .DESCRIPTION This function simply get a custom object as an input an convert it to the standard [Parmis.Solarwinds.Volume] class .EXAMPLE PS> ConvertTo-SwVolume -Object $myCustomObject Id : 4321 Index : 2 Name : D:\ Label:Data 907C96B8 Letter : D Node : Cosmos.Solarwinds.Node VolumeType : Fixed Disk Size : 107236814848 UsagePercentage : 18.30757 QueueLength : 6E-06 LastSync : 02/18/2024 8:00:59 AM Status : 1 Uri : swis://MainPoller.Contoso.com/Orion/Orion.Nodes/NodeID=1234/Volumes/VolumeID=4321 #> [Cmdletbinding()] [OutputType([Parmis.Solarwinds.Volume])] Param ( [Parameter(Mandatory = $true)] $Object ) Write-Verbose -Message "Converting to target object ..." $output = [Parmis.Solarwinds.Volume]::new() $output.Id = $Object.VolumeId $output.Index = $Object.VolumeIndex $output.Name = $Object.Caption $output.VolumeType = $Object.VolumeType $output.UsagePercentage = $Object.VolumePercentUsed $output.Size = $Object.VolumeSize $output.Status = $Object.Status $output.Uri = $Object.Uri $output.Node = Get-SwNode -InfoServiceProxy $InfoServiceProxy -Id $Object.NodeId if ($Object.DeviceId.Length -eq 2 -and $Object.DeviceId[1] -eq ':'){ $output.Letter = $Object.DeviceId[0] } if($Object.LastSync -isnot [System.DBNull]){ $output.LastSync = $Object.LastSync } if($Object.DiskQueueLength -isnot [System.DBNull]){ $output.QueueLength = $Object.DiskQueueLength } else{ $output.QueueLength = 0 } return $output } |