Possible to assign tape in slot to mediapool?

PowerShell script exchange

Possible to assign tape in slot to mediapool?

Veeam Logoby ercang » Tue Mar 25, 2014 2:07 pm

Hi all,

is it possible via PowerShell Script to assign all unrecognized Tapes to special Mediapools based on the Slot the Tape is in?
Example:
Tape 9 is in Slot 2, so i want it to be in the Tuesday Mediapool. All Slot 2 Tapes should be automatically moved in the Tuesday Mediapool.
I´am not so advanced using the Veeam Power Shell and have no idea how or if i can access the Slotinformation of a Tape.

Any help would be greatly appreciated.

Thank you
ercang
Novice
 
Posts: 4
Liked: never
Joined: Wed Sep 11, 2013 8:06 am
Full Name: Ercan Güven

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby v.Eremin » Tue Mar 25, 2014 3:07 pm

Hi, Ercan,

So, you want to move tape medium that is present in slot 2 of "Unrecognized" Media Pool to the given media pool, right? I haven't tested the following script in the environment, but, from my perspective, it should do the trick:

Code: Select all
$MediaPool = Get-VBRTapeMediaPool -name "Unrecognized"
$TargetMediaPool = Get-VBRTapeMediaPool -name "Name of target media pool"
$MediaPool | Get-VBRTapeMedium | where {$_.location.address -eq "2"} | Move-VBRTapeMedium -MediaPool $TargetMediaPool


Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby ercang » Tue Mar 25, 2014 4:07 pm

Hi Vladimir,

thank you. I tried you script.
First it seems, that $_.location.address -eq must be one to access the second slot. No problem here.
But when i execute the script i get the following error:
Code: Select all
Move-VBRTapeMedium : Methode nicht gefunden: "Void Veeam.Tape.Core.TapeMedium.C
lean()".
Bei C:\Users\admin\Desktop\move_mediapool.ps1:3 Zeichen:90
+ $MediaPool | Get-VBRTapeMedium | where {$_.location.address -eq "1"} | Move-V
BRTapeMedium <<<<  -MediaPool $TargetMediaPool
    + CategoryInfo          : NotSpecified: (:) [Move-VBRTapeMedium], MissingM
   ethodException
    + FullyQualifiedErrorId : System.MissingMethodException,Veeam.Backup.Power
   Shell.Command.MoveVBRTapeMedium


Any suggestions?

Thank you so much
ercang
Novice
 
Posts: 4
Liked: never
Joined: Wed Sep 11, 2013 8:06 am
Full Name: Ercan Güven

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby v.Eremin » Tue Mar 25, 2014 4:19 pm

I'm wondering whether you're running the said script under administrator account. Also, the missing parameter/method errors are typically related an outdated Powershell version. So, be sure to update PS to at least 3.0. In addition, sometimes reinstalling PS snap-in helps to get rid of the said issues.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby ercang » Tue Mar 25, 2014 5:11 pm

Hi Vladimir,

reinstalling VEEAM Patch did the trick.

Thank you so much.
ercang
Novice
 
Posts: 4
Liked: never
Joined: Wed Sep 11, 2013 8:06 am
Full Name: Ercan Güven

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby v.Eremin » Tue Mar 25, 2014 7:37 pm

I haven't had an opportunity to test the script, so, let me know whether it works as expected. Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby ercang » Thu Mar 27, 2014 9:09 am

Hi Vladimir,

the script works as expected. I´ve made a few changes to assign all tapes from the drive to the defined mediapools after making an tape inventory.

Attached my used example.
Code: Select all
Start-VBRTapeInventory -Library "Name of the Tape Library"
Get-VBRTapeDrive | Eject-VBRTapeDrive

$monday = Get-VBRTapeMediaPool -name "Monday"
#Using the first to slots for Monday
$tape = Get-VBRTapeMedium | where {$_.location.address -eq "0" -or $_.location.address -eq "1"} 
Move-VBRTapeMedium -Medium $tape -MediaPool $monday -Confirm:$false


Thank you so much!

Ercan
ercang
Novice
 
Posts: 4
Liked: never
Joined: Wed Sep 11, 2013 8:06 am
Full Name: Ercan Güven

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby v.Eremin » Thu Mar 27, 2014 9:32 am

Glad to hear my input was helpful. Should any other help be needed, don't hesitate to let me know. Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] Move to Free from specific slot

Veeam Logoby BayanInv » Thu Aug 11, 2016 12:20 pm

We have set Slot# 6 as our weekly tape slot, where we add weekly tape to that slot.

It is not possible from v9 to set tapes slots to be used in weekly tape jobs. (it was possible in BackupExec).
Even the support guys wont help us in powershell scripts.

How can I run a script to move tape from slot#6 to free media pool before my weekly job starts.
And can we add scripts in Jobs, So the Job starts as scheduled?

I have modified the script from another thread (powershell-f26/possible-to-assign-tape-in-slot-to-mediapool-t21160.html):
Code: Select all
Start-VBRTapeInventory -Library "Name of the Tape Library"
Get-VBRTapeDrive | Eject-VBRTapeDrive

$monday = Get-VBRTapeMediaPool -name "Monday"
#Using the first to slots for Monday
$tape = Get-VBRTapeMedium | where {$_.location.address -eq "0" -or $_.location.address -eq "1"} 
Move-VBRTapeMedium -Medium $tape -MediaPool $monday -Confirm:$false


I am new to the Veeam Backup.
BayanInv
Influencer
 
Posts: 10
Liked: never
Joined: Sun Aug 07, 2016 9:54 am
Full Name: BayanINV

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby PTide » Thu Aug 11, 2016 2:23 pm 1 person likes this post

Hi and welcome to the community!

This will move tape from the "Media Pool 1" media pool Slot 6 to the "Free" media pool, please note that you should specify Slot minus 1 in a script as the numeration actually starts from zero:

Code: Select all
$free = Get-VBRTapeMediaPool -Name "Free"
$pool = Get-VBRTapeMediaPool -Name "Media Pool 1"
$tape = Get-VBRTapeMedium -MediaPool $pool | where {$_.Location.SlotAddress -eq "5"}
Move-VBRTapeMedium -Medium $tape -MediaPool $free

Use pre/post-job script settings in order to start the script before/after the job.

Thanks.
PTide
Veeam Software
 
Posts: 3021
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby BayanInv » Sun Aug 21, 2016 6:02 am

This weekly I applied the script, and I got a warning message:
"Pre-job script terminated with exit code 255"

Also I noticed a Tape library discovery job, in running mode but status as idle?

What is this warning about?
BayanInv
Influencer
 
Posts: 10
Liked: never
Joined: Sun Aug 07, 2016 9:54 am
Full Name: BayanINV

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby v.Eremin » Mon Aug 22, 2016 10:28 am

Can you test the provided script manually and see whether it generates any error? Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby BayanInv » Fri Aug 26, 2016 10:55 am

@v.Eremin I tried the manually, and it failed below is the errors:

Code: Select all
PS C:\> . c:\Weekly.ps1
Get-VBRTapeMediaPool : The term 'Get-VBRTapeMediaPool' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Weekly.ps1:1 char:9
+ $free = Get-VBRTapeMediaPool -Name "Free"
+         ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-VBRTapeMediaPool:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Get-VBRTapeMediaPool : The term 'Get-VBRTapeMediaPool' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Weekly.ps1:2 char:9
+ $pool = Get-VBRTapeMediaPool -Name "Weekly"
+         ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-VBRTapeMediaPool:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Get-VBRTapeMedium : The term 'Get-VBRTapeMedium' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At C:\Weekly.ps1:3 char:9
+ $tape = Get-VBRTapeMedium -MediaPool $pool | where {$_.Location.SlotAddress -eq  ...
+         ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-VBRTapeMedium:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Move-VBRTapeMedium : The term 'Move-VBRTapeMedium' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At C:\Weekly.ps1:4 char:1
+ Move-VBRTapeMedium -Medium $tape -MediaPool $free
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Move-VBRTapeMedium:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
BayanInv
Influencer
 
Posts: 10
Liked: never
Joined: Sun Aug 07, 2016 9:54 am
Full Name: BayanINV

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby v.Eremin » Fri Aug 26, 2016 11:13 am

In order to get access to VB&R specific commandlets you have to load VB&R snap-in first. Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Possible to assign tape in slot to mediapool?

Veeam Logoby BayanInv » Sun Aug 28, 2016 5:45 am

Do I need to add that
Code: Select all
Add-PSSnapin VeeamPSSnapin
command at the start of the script?
Code: Select all
Add-PSSnapin VeeamPSSnapin
$free = Get-VBRTapeMediaPool -Name "Free"
$pool = Get-VBRTapeMediaPool -Name "Weekly"
$tape = Get-VBRTapeMedium -MediaPool $pool | where {$_.Location.SlotAddress -eq "5"}
Move-VBRTapeMedium -Medium $tape -MediaPool $free
BayanInv
Influencer
 
Posts: 10
Liked: never
Joined: Sun Aug 07, 2016 9:54 am
Full Name: BayanINV

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests