PowerShell script exchange
Post Reply
Teakers
Lurker
Posts: 2
Liked: never
Joined: Feb 17, 2014 1:20 pm
Full Name: Dennis Bromberg
Contact:

PowerShell Scripting Problem

Post by Teakers »

Hello,

in the past we used a Powershell script to backup one single machine into a Group. That worked very good. After we deployed on the veeam 7.0 we have to make changes on the script.

On that point I recognized that there are two different results:

First Result:
When I type "get-vbrjob" on a normal powershell commandbox he gives me a lot of information about the structure of my vbr-jobs. This information are useless to restart a single machine for that.

Second Result:
When I type "get-vbrjob" and start the powershell-console from the veeam application I get a table about my backup jobs.

My question at this point: Is there some kind of module missing in my powershell enviorment which is loading in the veeam powershell application?

The veeam powershell plugins are installed in both ways.

Thank you for your help in advance! :)
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: PowerShell Scripting Problem

Post by tsightler » 1 person likes this post

Actually, both commands are returning the exact same objects, but when you start via the Powershell console option from within Veeam it calls an initialize script which loads some additional formatting information to make the output of the command a little more human readable. For the full details (with a few minor mistakes but the jist is correct) you can read this thread.

Or, if you just want to jump to the "how do I manually load this formatting info so that it looks the same" then the following code should work:

Code: Select all

Add-PSSnapin VeeamPSSnapIn
$snapIn = Get-PSSnapIn "VeeamPSSnapIn"
$xmlFilePath = [System.IO.Path]::Combine($snapIn.ApplicationBase, "Veeam.Backup.PowerShell.format.ps1xml")
update-formatdata -prependPath $xmlFilePath
Petrie
Enthusiast
Posts: 29
Liked: 2 times
Joined: Oct 24, 2012 11:17 am
Full Name: Helge Hagedorn
Contact:

Re: PowerShell Scripting Problem

Post by Petrie »

tsightler wrote:Or, if you just want to jump to the "how do I manually load this formatting info so that it looks the same" then the following code should work:
Tom, thank you very much! Now we know why the output within the two PS sessions is different.

But unfortunately this does not solve another problem (we thought it was because of the different formatting):

When we do something like this...

Code: Select all

Get-VBRjob -name Test123 | Start-VBRJob
...it works as expected when started in a "Veeam Powershell session".


In a "normal" Powershell session (where the Veeam-Snapin has been invoked by the "Add-PSSnapIn" command) we keep getting this error:

Code: Select all

Start-VBRJob : Exception has been thrown by the target of an invocation.
At line:1 char:40
+ Get-VBRjob -name Test123 | Start-VBRJob
+                                        ~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Start-VBRJob], TargetInvocationException
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Veeam.Backup.PowerShell.Command.StartVBRJob
What are we doing wrong?
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: PowerShell Scripting Problem

Post by veremin »

Hi, Helge, I'm wondering whether you're running the said script under administrator account. Thanks.
Petrie
Enthusiast
Posts: 29
Liked: 2 times
Joined: Oct 24, 2012 11:17 am
Full Name: Helge Hagedorn
Contact:

Re: PowerShell Scripting Problem

Post by Petrie »

Started with elevated rights, everything works fine.
How embarrassing is that rookie mistake, - sorry! :oops:

Of course - and as expected - this does NOT depend on the output formatting of the "Get-VBRJob" command. :wink:

The reason why we did not realize the difference is that the "Veeam PS session" does not ask for elevated rights as VBR already runs with administrative rights (and asks for it when starting the GUI).
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: PowerShell Scripting Problem

Post by veremin »

No problem. Sometimes, these things might slip out of your attention. :)

Should any other questions arise, feel free to contact us.

Thanks.
Petrie
Enthusiast
Posts: 29
Liked: 2 times
Joined: Oct 24, 2012 11:17 am
Full Name: Helge Hagedorn
Contact:

Re: PowerShell Scripting Problem

Post by Petrie »

Thanks a lot!
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests