PowerShell script exchange
Post Reply
lwarrenkc
Lurker
Posts: 2
Liked: 1 time
Joined: Jan 27, 2014 4:02 pm
Full Name: Lee Warren
Contact:

Tape Media Pool Report PS script no longer works in V8

Post by lwarrenkc »

To the PowerShell guru's. Would anybody be able to fix this script so that it will run under the V8 B&R. We had this working great in V7 s0 we could get a list of our tapes and what Media Pools they were in. I have searched over the community and the documentation on powershell but I'm just not that good with PS to come up with the answer.

Get-VBRTapeMedium |
where {$_.FindMediaPool().name -ne ""}
Select-Object -Property @{N="Name";E={$_.Name}}, @{N="Barcode";E={$_.Barcode}},@{N="Media Pool";E={$_.FindMediaPool().name}},@{N="Retention";E={$_.FindMediaPool().Options.OverwritePeriod.value}}, @{N="Last write";E={$_.LastWriteTime}}, @{N="Overwrite date";E={$_.lastwritetime + $_.FindMediaPool().Options.OverwritePeriod.ToTimeSpan()}} |
Convertto-HTML -head $a -body $header |
Out-file C:\reports\VeeamTapeReport\VeeamMediaPool.html



Thanks,

Lee Warren
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Tape Media Pool Report PS script no longer works in V8

Post by veremin »

Hi, Lee,

Try the following example and see whether it meets your expectations:

Code: Select all

asnp VeeamPSSnapin
Get-VBRTapeMedium | Select-Object -Property @{N="Name";E={$_.Name}}, @{N="Barcode";E={$_.Barcode}},@{N="Media Pool";E={(Get-VBRTapeMediaPool -Id $Medium.MediaPoolId).name}},@{N="Expiration Date";E={$_.expirationDate}}, @{N="Last write time";E={$_.LastWriteTime}}
Thanks.
CharlesC
Novice
Posts: 8
Liked: 2 times
Joined: Feb 13, 2015 9:00 pm
Contact:

Re: Tape Media Pool Report PS script no longer works in V8

Post by CharlesC »

Hi PS Guru's,

I need help on this script as it used to work prior to v8.

$senderAddress = "fake@fake.com"
$recipients1 = "test@test.com"
$recipients2 = "test1@test1.com"

$jobName = "Backup Tape"
$EXserverIP = "tape.backup.com"

$secpasswd = ConvertTo-SecureString "1234567" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("fake@fake.com", $secpasswd)

$job = get-vbrtapejob | ? {$_.name -eq $jobName}
$result1 = $job.GetLastState()
$result2 = $job.GetLastResult()
if ($result1 -ne "Stopped" -or $result2 -ne "Success")
{
$strMessage = "The Veeam job ", $job.Name, " is still running or completed with error. Please check the status of the Replication job."

send-mailmessage -to $recipients1,$recipients2 -from $senderAddress -subject "$strMessage" -body "$strMessage" -smtpserver $EXserverIP -credential $mycreds -priority High -dno onSuccess, onFailure


}
else
{
$strMessage = "The Veeam job ", $job.Name, " was successful."
send-mailmessage -to $recipients1,$recipients2 -from $senderAddress -subject "$strMessage" -body "$strMessage" -smtpserver $EXserverIP -credential $mycreds -dno onSuccess, onFailure
}
start-sleep 5
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Tape Media Pool Report PS script no longer works in V8

Post by veremin »

LastState and LastResult are now static properties, not dynamic methods. Based on that, you can implement the corresponding changes:

Code: Select all

$result1 = $job.LastState
$result2 = $job.GetLastResult
Thanks.
CharlesC
Novice
Posts: 8
Liked: 2 times
Joined: Feb 13, 2015 9:00 pm
Contact:

Re: Tape Media Pool Report PS script no longer works in V8

Post by CharlesC »

great it works, thanks!
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Tape Media Pool Report PS script no longer works in V8

Post by veremin »

Just be aware that now those properties are static in their nature. Meaning, if previously you could have something like this, and everything worked as expected:

Code: Select all

$TapeJob = Get-VBRTapeJob -name "Name of your tape job"
do
{...}while ($TapeJob.GetLastState() -ne "Stopped")
Now, you'll have to change the script slightly, so that, last state property gets updated inside a cycle:

Code: Select all

do
{
$TapeJob = Get-VBRTapeJob -name "Name of your tape job"
....
}while ($TapeJob.LastState -ne "Stopped")
Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests