I am trying to look for the Media Pool Name variable to show what category each of the tapes belong to. Also I am trying to look for the Tape Library Name, however I cannot find the variables for these.
I think I have to combine another Get-VBR but I don't know how to combine two Get statements. Any help would be appreciated!
Looping through each tape medium can help. Also, as a best practice, I'd assign all possible calculations to variables before passing them to property expressions:
# Get all tape mediums
$tapemediums = Get-VBRTapeMedium | Sort-Object {$_.Barcode}
# Build null array
$tapeInfo = @()
# Loop through each tape medium
foreach ($tapemedium in $tapemediums) {
# Perform calculations
if ($tapemedium.IsExpired -eq $True)
{ $expiration = 'Expired' }
else
{ $expiration = $tapemedium.ExpirationDate }
$capacity = [math]::Round($tapemedium.Capacity/1TB, 2), "TB"
$freeSpace = [math]::Round($tapemedium.Free/1TB, 2), "TB"
$location = [System.String]::Join(", ", $tapemedium.Location, $tapemedium.Location.SlotAddress)
# Get media pool for current tape medium by media pool id
$mediapool = Get-VBRTapeMediaPool | where {$_.Id -eq $tapemedium.MediaPoolId}
# Get library for current tape medium by library id
$library = Get-VBRTapeLibrary | where {$_.Id -eq $tapemedium.LibraryId}
# Add newly built hashtable to $tapeInfo array in every loop cycle
$tapeInfo += $tapemedium |Select-Object -Property @{N="Barcode";E={$_.Barcode}},
@{N="Location";E={$location}},
@{N="IsExpired";E={$expiration}},
@{N="Media Set";E={$_.MediaSet}},
@{N="Capacity";E={$capacity}},
@{N="Free Space";E={$freeSpace}},
@{N="Media Pool";E={$mediapool.Name}},
@{N="Library";E={$library.Name}}
}
# Export array of constructed objects to csv file
$tapeInfo | Export-Csv -Path C:\Temp\VEEAMInventory.csv -Append