Calling Stop-VSBJob via output of Get-VSBJob

PowerShell script exchange

Calling Stop-VSBJob via output of Get-VSBJob

Veeam Logoby mdsella » Thu Jun 27, 2013 2:31 pm

I am currently working on scheduling the automated start/stop of a couple SureBackup jobs via PowerShell and Windows Scheduled tasks.

While working on this I have had problems executing the following commands:

Code: Select all
Get-VSBJob -name "SB Job Name" | Start-VSBJob
Get-VSBJob -name "SB Job Name" | Stop-VSBJob


Both of these commands fail when executed through either ISE or a generic PowerShell console. In both cases I registered the VeeamPSSnapin. If I execute the same commands via PowerShell remote (my workstation to the Veeam server) the commands run perfectly. Is there anything I'm missing about running these commands locally on the Veeam server?

Thanks in advance.
mdsella
Novice
 
Posts: 3
Liked: never
Joined: Thu Jun 27, 2013 2:13 pm
Full Name: Michael Sella

Re: Calling Stop-VSBJob via output of Get-VSBJob

Veeam Logoby v.Eremin » Thu Jun 27, 2013 2:38 pm

Hi, Michael. I'm wondering with what particular message the script failed.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Calling Stop-VSBJob via output of Get-VSBJob

Veeam Logoby mdsella » Thu Jun 27, 2013 2:42 pm

Here is the PowerShell message that is received:

Code: Select all
PS C:\Users\admveeam> Get-VSBJob -name "SB Job Name" | Start-VSBJob
Start-VSBJob : Exception has been thrown by the target of an invocation.
At line:1 char:31
+ Get-VSBJob -name "SB Job Name" | Start-VSBJob
+                               ~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Veeam.Backup.Po...and.StartVSBJob:StartVSBJob) [Start-VSBJob], TargetInvocationException
    + FullyQualifiedErrorId : Backup,Veeam.Backup.PowerShell.Command.StartVSBJob
mdsella
Novice
 
Posts: 3
Liked: never
Joined: Thu Jun 27, 2013 2:13 pm
Full Name: Michael Sella

Re: Calling Stop-VSBJob via output of Get-VSBJob

Veeam Logoby v.Eremin » Thu Jun 27, 2013 2:51 pm 1 person likes this post

Hmm, might be an account issue. Are you running this script as Administrator? If not, give it a shot, and see whether it helps or not. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Calling Stop-VSBJob via output of Get-VSBJob

Veeam Logoby mdsella » Thu Jun 27, 2013 3:03 pm

While logged in with a user account that is a local administrator on the server, I opened two PowerShell consoles side by side (one using the "run as administrator"). I tested the commands in the standard PowerShell sonsole first and in both cases the commands failed. When running each of the commands in the (run as admin) console they both worked like a charm.

Thank you for the prompt follow-up and fix Vladimir!
mdsella
Novice
 
Posts: 3
Liked: never
Joined: Thu Jun 27, 2013 2:13 pm
Full Name: Michael Sella

Re: Calling Stop-VSBJob via output of Get-VSBJob

Veeam Logoby v.Eremin » Thu Jun 27, 2013 3:06 pm

You’re welcome. Feel free to contact me, should any additional help be needed. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 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 5 guests