PowerShell script exchange
Post Reply
andrewfox68
Enthusiast
Posts: 33
Liked: 2 times
Joined: Oct 29, 2016 10:13 pm
Full Name: Andrew Fox
Contact:

Tape media and library report

Post by andrewfox68 »

I am looking to create a report that lists written to tape media in multiple tape libraries for Veeam.

The command to list the tape media is:

Code: Select all

Get-VBRTapeMedium | Where-Object {$_.LastWriteTime -ge 4 -and $_.Location -like "S*"} | Sort-Object {$_.Barcode} |Select-Object -Property @{N="Barcode";E={$_.Barcode}}, @{N="Location";E={$_.Location}}, @{N="SlotNo";E={$_.Location.SlotAddress +1}}, @{N="Library";E={$_.LibraryId}}
The output is shown as:

B

Code: Select all

arcode                                Location                                                       SlotNo       Library
-------                                   --------                                                            ------       -------
ZZ0018L5                              Slot                                                                    43       15c930a1-156b-48aa-8b29-4ff3b56ab123
ZZ0016L5                              Slot                                                                    15       15c930a1-156b-48aa-8b29-4ff3b56ab123
ZZ0014L5                              Slot                                                                    37       8fe52e59-ed9c-4294-8a43-fa345ac890fad
ZZ0028L5                              Slot                                                                    37       15c930a1-156b-48aa-8b29-4ff3b56ab123
ZZ0024L5                              Slot                                                                    47       8fe52e59-ed9c-4294-8a43-fa345ac890fad
ZZE029L5                              Slot                                                                    42       8fe52e59-ed9c-4294-8a43-fa345ac890fad
ZZ0203L5                              Slot                                                                    48       8fe52e59-ed9c-4294-8a43-fa345ac890fad
ZZ0281L5                              Slot                                                                    41       8fe52e59-ed9c-4294-8a43-fa345ac890fad
ZZ0286L5                              Slot                                                                    45       15c930a1-156b-48aa-8b29-4ff3b56ab123
ZZ0397L5                              Slot                                                                    42       15c930a1-156b-48aa-8b29-4ff3b56ab123
ZZ0343L5                              Slot                                                                    14       f458dcc0-b506-4a0d-9329-86afd213bd65
ZZ0388L5                              Slot                                                                    10       f458dcc0-b506-4a0d-9329-86afd213bd65
……list truncated

The library column shows the ID of the library and I need a report that shows the name of the library as it is more meaningful.


The command to list the libraries is Get-VBRTapeLibrary and shows the following output:

Code: Select all

Drives       : {Tape2147483640, Tape2147483639, Tape2147483644, Tape2147483643}
Enabled      : True
Model        : MSL G3 Series
Slots        : 96
TapeServerId : bfcf4573-b06d-4df0-9964-89def345bcaf
Type         : Automated
State        : Online
Id           : 15c930a1-156b-48aa-8b29-4ff3b56ab123
Name         : MSL-8096-04
Description  :

Drives       : {Tape0, Tape1}
Enabled      : True
Model        : MSL G3 Series
Slots        : 48
TapeServerId : df46e032-e46b-4ed7-b3f0-45bfa76de345
Type         : Automated
State        : Online
Id           : f458dcc0-b506-4a0d-9329-86afd213bd65
Name         : MSL-8096-03-01
Description  :

Drives       : {Tape2, Tape3, Tape4, Tape5}
Enabled      : True
Model        : MSL G3 Series
Slots        : 96
TapeServerId : df46e032-e46b-4ed7-b3f0-fe4bc456ae87
Type         : Automated
State        : Online
Id           : 8853845a-6101-4184-b06c-3dce4af341
Name         : ER-8096-05
Description  :

Drives       : {Tape2147483646, Tape2147483645}
Enabled      : True
Model        : MSL G3 Series
Slots        : 48
TapeServerId : bfcf4573-b06d-4df0-9964-089aaf0b1e8d
Type         : Automated
State        : Online
Id           : 8fe52e59-ed9c-4294-8a43-fa345ac890fad
Name         : MSL8096-03-02
Description  :

I am interested in the tape library ID and Name and running the following command:

Code: Select all

Get-VBRTapeLibrary | Select-Object -Property @{N="ID";E={$_.ID}}, @{N="Name";E={$_.Name}}
Gives the following output:

Code: Select all

ID                                                                   Name
--                                                                    ----
15c930a1-156b-48aa-8b29-4ff3b56ab123          MSL-8096-04
f458dcc0-b506-4a0d-9329-86afd213bd65          MSL-8096-03-01
8853845a-6101-4184-b06c-3dce4af341             MSL-8096-05
8fe52e59-ed9c-4294-8a43-fa345ac890fad         MSL-8096-03-02

Is there a command or script that can be created to do a lookup of the library name and show it in the first report instead of the library ID or command that can be run that gives me the information required?

Many thanks.

Andrew
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Tape media and library report

Post by veremin »

I cannot test that in the moment, but in the way I see it the following script should work fine:

Code: Select all

Get-VBRTapeMedium | Where-Object {$_.LastWriteTime -ge 4 -and $_.Location -like "S*"} | Sort-Object {$_.Barcode} |Select-Object -Property @{N="Barcode";E={$_.Barcode}}, @{N="Location";E={$_.Location}}, @{N="SlotNo";E={$_.Location.SlotAddress +1}}, @{N="Library";E={(Get-VBRTapeLibrary -id ($_.LibraryId)).name}}
Thanks.
andrewfox68
Enthusiast
Posts: 33
Liked: 2 times
Joined: Oct 29, 2016 10:13 pm
Full Name: Andrew Fox
Contact:

Re: Tape media and library report

Post by andrewfox68 » 1 person likes this post

That worked.

Many, many thanks for the reply and solution.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Tape media and library report

Post by veremin »

You're welcome. Feel free to ask for additional help, if needed.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests