PowerShell script exchange
Post Reply
falkob
Veeam Vanguard
Posts: 86
Liked: 31 times
Joined: Sep 28, 2017 7:47 am
Full Name: Falko Banaszak
Contact:

Mark Expired Tape as Free

Post by falkob »

Hello folks !

I have a problem regarding GFS Media Pools.

I have several Tapes which are marked as "expired" but the GFS job doesn't take these Tapes to write backup data to, because they belonged to different media sets.

So iam trying to achieve the following:

Search for "Expired" Tapes via PowerShell and "mark them as free" after finding the expired tapes.

Does anybody have a script for that ?

Thank you !
VCP6.5-DCV, VCP6-DCV, VMCE, VMCA, Veeam Vanguard, VMware vExpert
https://www.virtualhome.blog
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Mark Expired Tape as Free

Post by veremin »

I don't have console at hand, but the script should look similar to the following:

Code: Select all

$free = Get-VBRTapeMediaPool -Name "Free"
$pool = Get-VBRTapeMediaPool -Name "Name of your media pool"
$tape = Get-VBRTapeMedium -MediaPool $pool | where {$_.isExpired -eq $True}
Move-VBRTapeMedium -Medium $tape -MediaPool $free
Thanks.
Ostrich
Lurker
Posts: 1
Liked: never
Joined: Oct 01, 2021 7:25 am
Contact:

Re: Mark Expired Tape as Free

Post by Ostrich »

HI,

here is an exampel, how to use "Move-VBRTapeMedium" to free media pool and back to original mediapool.

Code: Select all

#if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

Start-Transcript -Path $PSScriptRoot\DebugFreeTapes.txt
asnp VeeamPSSnapin
$tapes = Get-VBRTapeMedium | Where-Object {$_.IsExpired -eq 1}


foreach($tape in $tapes)
{
    Write-Output "Move $($tape.name) to free..."
    
    $tmpPoolId = $tape.MediaPoolId
    $tmpPool = Get-VBRTapeMediaPool -Id $tmpPoolId


    Move-VBRTapeMedium -Medium $tape.Name -MediaPool Free 
    Sleep 1
    Write-Output "Move $($tape.name) to $($tmpPool.Name)..."

    Move-VBRTapeMedium -Medium $tape.Name -MediaPool $tmpPool.Name
}
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests