PowerShell script exchange
Post Reply
anthony.quepons
Novice
Posts: 6
Liked: never
Joined: Jul 01, 2020 4:23 pm
Full Name: Anthony Quepons
Contact:

Deleting Archived VTL Tapes

Post by anthony.quepons »

Does anybody have a handy Powershell command that can reach into AWS via AWS CLI or Powershell to delete archived VTL Tapes in storage gateway? I know I could log into the AWS gateway manually on a monthly basis and delete that way. But it would be nice to just setup a Powershell job that would reach into the storage gateway and delete. Thank you.

oleg.feoktistov
Veeam Software
Posts: 977
Liked: 356 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Deleting Archived VTL Tapes

Post by oleg.feoktistov »

Hi,

If it comes to powershell, you might need to use AWS.Tools.StorageGateway module for that.
I delete unused tapes with the script below adapted for archived tapes as per your question:

Code: Select all

$tapes = Get-SGTape -Region eu-west-3
foreach ($tape in $tapes) {
  $archived = Get-SGTapeArchive -TapeARN $tape.TapeARN  -GatewayARN $tape.GatewayARN -Region eu-west-3
  Remove-SGTapeArchive -TapeARN $archived.TapeARN -Region eu-west-3
} 
I'm sure there is also a bunch of examples for aws cli and SDKs for the same action.
I tend to use Javascript SDK quite often, so I'd probably research this method.

Hope it helps,
Oleg

stuart_little1874
Influencer
Posts: 22
Liked: 4 times
Joined: Jul 22, 2020 1:25 pm
Full Name: Stuart Little
Contact:

Re: Deleting Archived VTL Tapes

Post by stuart_little1874 »

Can this script be modified to delete tapes (based on an input file that contains barcodes) ?

oleg.feoktistov
Veeam Software
Posts: 977
Liked: 356 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Deleting Archived VTL Tapes

Post by oleg.feoktistov »

You can just get file contents firsthand and then iterate through each barcode to filter tapes by a tape barcode name. Example:

Code: Select all

$barcodes = Get-Content $barcodes.txt
$tapes = Get-SGTape -Region eu-west-3
foreach ($barcode in $barcodes) {
 $tape =$tapes | where {$_.TapeBarcode -eq $barcode}
 ...
}

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests