PowerShell script exchange
Post Reply
Rick.Vanover
Veeam Software
Posts: 554
Liked: 118 times
Joined: Nov 30, 2010 3:19 pm
Full Name: Rick Vanover
Location: Columbus, Ohio USA
Contact:

Start-VBRZip in Veeam Backup Free Edition

Post by Rick.Vanover » May 11, 2015 10:51 am 4 people like this post

I just posted the blog post from Vladimir about Update 2 brining PowerShell support:

http://www.veeam.com/blog/veeam-backup- ... shell.html

It's better if any discussions for the script are here rather than blog comments, so let's get scripting!

cowboy6
Lurker
Posts: 1
Liked: never
Joined: May 12, 2015 12:02 pm
Full Name: Gregor Godler
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by cowboy6 » May 12, 2015 12:11 pm

Great post/news about this new feature. I'm having some trouble with script from here: http://www.veeam.com/blog/wp-content/up ... eamZIP.zip

I get this error:



Find-VBRViEntity : Unable to cast object of type 'Veeam.Backup.Core.Infrastructure.CHvHostItem' to type 'Veeam.Backup.Core.Infrastructure.IViI
tem'.
At C:\scripts\backup_hyperv.ps1:78 char:9
+ $VM = Find-VBRViEntity -Name $VMName -Server $Server
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Find-VBRViEntity], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,Veeam.Backup.PowerShell.Command.FindVBRViEntity


v.Eremin
Product Manager
Posts: 15807
Liked: 1252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by v.Eremin » May 12, 2015 10:43 pm 1 person likes this post

It seems that you're using HV infrastructure, right? The script has been developed to vSphere deployment, so some of the lines need to be replaced with HV alternatives to make the script work.

We will provide HV version and attach it to the blog post soon.

Thanks.

v.Eremin
Product Manager
Posts: 15807
Liked: 1252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by v.Eremin » May 13, 2015 2:14 pm 1 person likes this post

Basically, you need to replace Find-VBRViEntity with its HV analogue - Find-VBRHvEntity. Thanks.

bobendicott
Lurker
Posts: 1
Liked: 1 time
Joined: Jan 05, 2015 1:18 am
Full Name: Bob Endicott
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by bobendicott » May 13, 2015 6:32 pm 1 person likes this post

I have tried to implement this script and it works great for a single VM but if I try to add multiple VM's to the script I receive the errors below.

Here is what I am putting in the VMName section of the script
# Names of VMs to backup separated by semicolon (Mandatory)
$VMNames = "VM1; VM2; VM3"

Start-VBRZip : Cannot validate argument on parameter 'Entity'. The argument is null. Provide a valid value for the
argument, and then try running the command again.
At C:\scripts\VeeamZIP.ps1:86 char:40
+ $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $Comp ...
+ ~~~
+ CategoryInfo : InvalidData: (:) [Start-VBRZip], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Commands.Backup.StartVBRZip

You cannot call a method on a null-valued expression.
At C:\scripts\VeeamZIP.ps1:91 char:5
+ $TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog().updatedrecords
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

thank you.

v.Eremin
Product Manager
Posts: 15807
Liked: 1252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by v.Eremin » May 16, 2015 2:30 pm 1 person likes this post

What happens if you try to separate them in the similar manner:

Code: Select all

$VMNames = "VM1", "VM2", "VM3"

gzartman
Lurker
Posts: 1
Liked: never
Joined: May 17, 2015 5:38 am
Full Name: Greg Zartman
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by gzartman » May 17, 2015 5:54 am

bobendicott wrote:I have tried to implement this script and it works great for a single VM but if I try to add multiple VM's to the script I receive the errors below.
.
I ran into the same issue with this powershell script. I am not super familiar with PS scripts, but all that $VMNames is doing is storing a list of VM names. I don't think that putting semi-colons inside the quotes is proper list syntax. Instead, the following syntax will work: $VMNames = "VM1","VM2"

In other words, VM names inside quotes separated by commas.

This has been testing on my machine and now the script works fine for multiple VMs.

Greg

v.Eremin
Product Manager
Posts: 15807
Liked: 1252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by v.Eremin » May 18, 2015 10:44 am 1 person likes this post

It should work with commas, indeed.

I'm now preparing list of modifications, and will ask Rick to upload them to the blog post later on.

Thanks.

Rick.Vanover
Veeam Software
Posts: 554
Liked: 118 times
Joined: Nov 30, 2010 3:19 pm
Full Name: Rick Vanover
Location: Columbus, Ohio USA
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by Rick.Vanover » May 18, 2015 4:09 pm 1 person likes this post


CTRidgeline
Novice
Posts: 7
Liked: 1 time
Joined: May 13, 2015 12:52 pm
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by CTRidgeline » May 18, 2015 5:47 pm

Good afternoon,

I have the script setup and it runs quite well, with the exception of the following err and nothing reported in the Details section of the email being sent. Any suggestions? I tried this with 1 server and 3 servers being backed up with the script and get the message for each server.

You cannot call a method on a null-valued expression.
At C:\Users\xxxxxxxx\Desktop\veeamzip-TEST.ps1:91 char:64
+ $TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog <<<< ().updatedrecords
+ CategoryInfo : InvalidOperation: (getlog:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull


Thank you for your assistance.

CTRidgeline
Novice
Posts: 7
Liked: 1 time
Joined: May 13, 2015 12:52 pm
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by CTRidgeline » May 18, 2015 6:06 pm

Sorry, I have question on this...

Is there a method for sending the email to multiple recipients? I tested it with two email addresses either as "1st@test.com;2nd@test.com" and "1st@test.com","2nd@test.com" and it appears that only the first email gets sent to the first address when it is together with the single set of quotes and sent to the last entry on the individual addresses with the quotes and comma.
Thanks!

v.Eremin
Product Manager
Posts: 15807
Liked: 1252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by v.Eremin » May 19, 2015 10:13 am

You cannot call a method on a null-valued expression.
It appears that $ZIPSession variable doesn't contain anything, may be VeeamZIP has been started against non-existent VM or something.
Is there a method for sending the email to multiple recipients?
I think you can create a list of recipients and, then, add a loop at e-mail sending stage, so that, email will be generated for multiple addresses.

Thanks.

CTRidgeline
Novice
Posts: 7
Liked: 1 time
Joined: May 13, 2015 12:52 pm
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by CTRidgeline » May 19, 2015 11:51 am

v.Eremin wrote: It appears that $ZIPSession variable doesn't contain anything, may be VeeamZIP has been started against non-existent VM or something.
The backup is running successfully and I can get the report emailed to me, but as you can see in the email report sample below (although it doesn't align right, there is another section at the end of each line for 'Details'), the detail is blank and I think this is tied back to the error that is being generated. I just can't figure why it is coming back as a null value.
Name Start Time End Time Result Details
SERVER1_2015-05-18T172527 5/18/2015 5:25:27 PM 5/18/2015 5:36:28 PM Success
SERVER2_2015-05-18T173633 5/18/2015 5:36:33 PM 5/18/2015 5:58:17 PM Success
SERVER3_2015-05-18T175820 5/18/2015 5:58:20 PM 5/18/2015 6:16:38 PM Success

v.Eremin wrote: I think you can create a list of recipients and, then, add a loop at e-mail sending stage, so that, email will be generated for multiple addresses.

Thanks.
OK, I will have to give that a try. Thanks for the pointers. :wink:

v.Eremin
Product Manager
Posts: 15807
Liked: 1252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by v.Eremin » May 19, 2015 12:27 pm

"Details" is blank due to $ZIPSession variable being indicated as null. Though, I'm not sure how it happens because $ZIPSession variable is used multiple times to get session specific information, such as start time, end time, etc (and those are reflected correctly).

CTRidgeline
Novice
Posts: 7
Liked: 1 time
Joined: May 13, 2015 12:52 pm
Contact:

Re: Discussion on blog post: Update 2 featuring PowerShell

Post by CTRidgeline » May 19, 2015 12:31 pm

v.Eremin wrote:"Details" is blank due to $ZIPSession variable being indicated as null. Though, I'm not sure how it happens because $ZIPSession variable is used multiple times to get session specific information, such as start time, end time, etc (and those are reflected correctly).
Yup, that is pretty much what my thoughts were, that it is correctly using the $ZIPSession variable to gather the start/end/status but seems to have an issue getting the detail.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest