PowerShell script exchange
Post Reply
ercang
Novice
Posts: 4
Liked: never
Joined: Sep 11, 2013 8:06 am
Full Name: Ercan Güven
Contact:

Possible to assign tape in slot to mediapool?

Post by ercang »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

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.
ercang
Novice
Posts: 4
Liked: never
Joined: Sep 11, 2013 8:06 am
Full Name: Ercan Güven
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by ercang »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

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.
ercang
Novice
Posts: 4
Liked: never
Joined: Sep 11, 2013 8:06 am
Full Name: Ercan Güven
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by ercang »

Hi Vladimir,

reinstalling VEEAM Patch did the trick.

Thank you so much.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

I haven't had an opportunity to test the script, so, let me know whether it works as expected. Thanks.
ercang
Novice
Posts: 4
Liked: never
Joined: Sep 11, 2013 8:06 am
Full Name: Ercan Güven
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by ercang »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

Glad to hear my input was helpful. Should any other help be needed, don't hesitate to let me know. Thanks.
BayanInv
Influencer
Posts: 10
Liked: never
Joined: Aug 07, 2016 9:54 am
Full Name: BayanINV
Contact:

[MERGED] Move to Free from specific slot

Post by BayanInv »

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- ... 21160.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.
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by PTide » 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.
BayanInv
Influencer
Posts: 10
Liked: never
Joined: Aug 07, 2016 9:54 am
Full Name: BayanINV
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by BayanInv »

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?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

Can you test the provided script manually and see whether it generates any error? Thanks.
BayanInv
Influencer
Posts: 10
Liked: never
Joined: Aug 07, 2016 9:54 am
Full Name: BayanINV
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by BayanInv »

@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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

In order to get access to VB&R specific commandlets you have to load VB&R snap-in first. Thanks.
BayanInv
Influencer
Posts: 10
Liked: never
Joined: Aug 07, 2016 9:54 am
Full Name: BayanINV
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by BayanInv »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

Do I need to add that
Correct. Thanks.
BayanInv
Influencer
Posts: 10
Liked: never
Joined: Aug 07, 2016 9:54 am
Full Name: BayanINV
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by BayanInv »

This is running me mad. Got another error:

Code: Select all

Error running pre-job script: The specified executable is not a valid application for this OS platform
Do I have to change the file extension to .bat as I used the .ps1 extension.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

You can specify the following command as a pre-job activity:

Code: Select all

Powershell.exe -File C:\YourScript.ps1
The script itself should start with "Add-PSSnapin VeeamPSSnapin".

Thanks.
BayanInv
Influencer
Posts: 10
Liked: never
Joined: Aug 07, 2016 9:54 am
Full Name: BayanINV
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by BayanInv »

Thanks,
My pre-job script is now Working Fine. To summarize
Created a script with extension .ps1, and added "Add-PSSnapin VeeamPSSnapin"

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
At the Job's Advance Setting window - under Job-scripts
enabled Run the following script before the job:

Code: Select all

Powershell.exe -File C:\Weekly.ps1
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Possible to assign tape in slot to mediapool?

Post by veremin »

I've created previously a post describing different ways to use PowerShell scripts as a pre/post-job activity; the suggest approach is mentioned there as well.

Anyway, glad to hear that everything works as expected for you.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests