Tape inventory and move to pool

PowerShell script exchange

Tape inventory and move to pool

Veeam Logoby Nieuwenhuis » Thu Jun 22, 2017 10:42 am

Hello

Browsing this site i found multiple ps scripts to inventory a tape drive and move media to a mediapool.
i can not get them to work i keep getting errors this might be because the scripts are for previous versions.
can someone assist me with a script that does a inventory and moves media from unrecognized to free media.
We need this since we are moving from backupexec to veeam with our tape drive.
this is the script i have found but it gives errors.
Code: Select all
Write-host “Prepare Tape for Veeam backup”
Add-PSSnapin VeeamPSSnapin
Get-VBRTapeDrive | Start-VBRTapeInventory
$MediaPool = Get-VBRTapeMediaPool -Name "Unrecognized"
$FreeMediaPool = Get-VBRTapeMediaPool -Name "Free"
$Mediums = $MediaPool | Get-VBRTapeMedium
Move-VBRTapeMedium -Medium $Mediums -MediaPool $MediaPool -Confirm:$false


Thank u
Nieuwenhuis
Service Provider
 
Posts: 5
Liked: never
Joined: Mon Sep 05, 2016 6:20 am

Re: Tape inventory and move to pool

Veeam Logoby v.Eremin » Thu Jun 22, 2017 11:17 am

On a surface the script looks OK, can you provide exact issues you came across? Thanks.
v.Eremin
Veeam Software
 
Posts: 13856
Liked: 1037 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Tape inventory and move to pool

Veeam Logoby Nieuwenhuis » Thu Jun 22, 2017 11:21 am

If i run the script i get the following
Code: Select all
PS C:\beheer> .\VeeamInventoryTape.ps1
Prepare Tape for Veeam backup


Progress     : 0
RunManually  : True
Log          : {}
CreationTime : 22-6-2017 13:19:59
EndTime      : 1-1-1900 0:00:00
JobId        : a144fa2f-8a63-4588-af1b-e36d33808730
Result       : None
State        : Starting
Id           : bcee622d-6e79-4617-8658-3da50acb4083

Get-VBRTapeMedium : A tape medium the specified name does not exist: Unrecognized
At C:\beheer\VeeamInventoryTape.ps1:6 char:25
+ $Mediums = $MediaPool | Get-VBRTapeMedium
+                         ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-VBRTapeMedium], Exception
    + FullyQualifiedErrorId : GetTapeMediumErrorId,Veeam.Backup.PowerShell.Cmdlets.GetVBRTapeMedium

Move-VBRTapeMedium : Cannot validate argument on parameter 'Medium'. The argument is null. Provide a valid value for th
e argument, and then try running the command again.
At C:\beheer\VeeamInventoryTape.ps1:7 char:28
+ Move-VBRTapeMedium -Medium $Mediums -MediaPool $MediaPool -Confirm:$false
+                            ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Move-VBRTapeMedium], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.MoveVBRTapeMedium

Nieuwenhuis
Service Provider
 
Posts: 5
Liked: never
Joined: Mon Sep 05, 2016 6:20 am

Re: Tape inventory and move to pool

Veeam Logoby v.Eremin » Thu Jun 22, 2017 12:04 pm

Try to declare $Medias variable differently:

Code: Select all
$MediaPool = Get-VBRTapeMediaPool -name "Unrecognized"
$Mediums = Get-VBRTapeMedium -MediaPool $MediaPool


Also, it worth checking whether all variables get assigned properly (just input variables one by one):

Code: Select all
$Mediapool
$Mediums
$FreeMediaPool
v.Eremin
Veeam Software
 
Posts: 13856
Liked: 1037 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Tape inventory and move to pool

Veeam Logoby Nieuwenhuis » Thu Jun 22, 2017 1:08 pm

Made the corrections u said.
$mediapool , lists stuff
$freemediapool , lists stuff
$mediums , gives no reply !
Code: Select all
Move-VBRTapeMedium -Medium $Mediums -MediaPool $MediaPool -Confirm:$false

Gives the following error
Code: Select all
PS C:\beheer> $Mediums
PS C:\beheer> Move-VBRTapeMedium -Medium $Mediums -MediaPool $MediaPool -Confirm:$false
Move-VBRTapeMedium : Cannot validate argument on parameter 'Medium'. The argument is null. Provide a valid value for th
e argument, and then try running the command again.
At line:1 char:28
+ Move-VBRTapeMedium -Medium $Mediums -MediaPool $MediaPool -Confirm:$false
+                            ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Move-VBRTapeMedium], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.MoveVBRTapeMedium


As said i want to run this before a job since we are moving from backup exec to veeam
i would like that media in unrecognized Pool gets moved to Free pool, so that veeam will use this tape and overwrite the old backupexec data with veeam data.
Nieuwenhuis
Service Provider
 
Posts: 5
Liked: never
Joined: Mon Sep 05, 2016 6:20 am

Re: Tape inventory and move to pool

Veeam Logoby v.Eremin » Thu Jun 22, 2017 2:25 pm

If $Mediums variable returns nothing, it means that there are no tapes in Unrecognized media pool. Can you provide screenshots, if possible?
v.Eremin
Veeam Software
 
Posts: 13856
Liked: 1037 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: christian.kotze and 1 guest