Tape Media Pool Report PS script no longer works in V8

PowerShell script exchange

Tape Media Pool Report PS script no longer works in V8

Veeam Logoby lwarrenkc » Wed Dec 17, 2014 8:27 pm

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
lwarrenkc
Lurker
 
Posts: 2
Liked: 1 time
Joined: Mon Jan 27, 2014 4:02 pm
Full Name: Lee Warren

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

Veeam Logoby v.Eremin » Thu Dec 18, 2014 9:46 am

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.
v.Eremin
Veeam Software
 
Posts: 13285
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

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

Veeam Logoby CharlesC » Fri Feb 13, 2015 9:03 pm

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
CharlesC
Novice
 
Posts: 8
Liked: 2 times
Joined: Fri Feb 13, 2015 9:00 pm

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

Veeam Logoby v.Eremin » Mon Feb 16, 2015 11:02 am

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.
v.Eremin
Veeam Software
 
Posts: 13285
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

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

Veeam Logoby CharlesC » Mon Feb 16, 2015 3:57 pm

great it works, thanks!
CharlesC
Novice
 
Posts: 8
Liked: 2 times
Joined: Fri Feb 13, 2015 9:00 pm

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

Veeam Logoby v.Eremin » Mon Feb 16, 2015 4:15 pm

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.
v.Eremin
Veeam Software
 
Posts: 13285
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 12 guests