Start a Veeam job from another machine

PowerShell script exchange

Start a Veeam job from another machine

Veeam Logoby electricd7 » Thu Jun 19, 2014 4:47 pm

Is there a way for me to install the Powershell tools on another guest and then connect to the Veeam server and fire off a backup job? I would like to be able to start jobs from guests VMs which are not Veeam Backup and Replication servers.
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

Re: Start a Veeam job from another machine

Veeam Logoby electricd7 » Thu Jun 19, 2014 7:59 pm

So I have been trying to go down the path of Invoke-Command within PowerShell and run the start job script on the remote Veeam backup and replication server. I am using the following line:

Invoke-Command -FilePath c:\scripts\test.ps1 -ComputerName Veeam1

The file test.ps1 does exist in the c:\scripts\ path on the local machine (the one running the calling script). If I run test.ps1 from the Veeam server in powershell it runs and the job starts.

When I call it from the remote machine using the invoke-command above I get errors almost like its trying to load the PowerShell snapin in the local machine. Can anyone direct me to a working call to start a job from within the powershell of another guest in the environment?
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

Re: Start a Veeam job from another machine

Veeam Logoby tsightler » Fri Jun 20, 2014 1:27 am

There are examples in the Getting Started and Code Examples section. Here's the link to a specific example.
tsightler
Veeam Software
 
Posts: 4772
Liked: 1740 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Start a Veeam job from another machine

Veeam Logoby electricd7 » Fri Jun 20, 2014 2:50 am

Thanks..I have seen those and have tried lots of ideas today. My error occurs when I fire the Add-PSSnapin command on the remote session. Here is a copy of the output including the error:

Code: Select all
PS C:\> $s = New-PSSession -Computername Veeam1
PS C:\> Enter-PSSession $s
[Veeam1]: PS C:\Users\ckillion\Documents> Add-PSSnapin VeeamPSSnapIn
Add-PSSnapin : Cannot load Windows PowerShell snap-in VeeamPSSnapIn because of the following error: Could not load file
 or assembly 'file:///C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.PowerShell.dll' or one of its d
ependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
    + CategoryInfo          : InvalidData: (VeeamPSSnapIn:String) [Add-PSSnapin], PSSnapInException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

Re: Start a Veeam job from another machine

Veeam Logoby electricd7 » Fri Jun 20, 2014 3:08 am

Just FYI, i just did the .\Install-VeeamToolkit.ps1 ran from remote B&R server on my remote powershell system and it appeared to enable me to be able to now add the snapin locally but obviously it doesn't work. I get the same error when trying to initiate calls against the remote server.
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

Re: Start a Veeam job from another machine

Veeam Logoby v.Eremin » Fri Jun 20, 2014 9:07 am

The code provided by you doesn't appear to be correct. Have you tried to use the right syntax referenced by Tom?

Code: Select all
$backupserver = "backup.demolab.an.veeam.de"
$username = "demolab\Administrator"
$password = convertto-securestring -string "Sumsi1!" -asplaintext -force
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $Username, $Password
$session = New-PSSession $backupserver #-authentication CredSSP -Credential $credentials
invoke-command -session $session -scriptblock {Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue; ScriptBlock}
Remove-PSSession $session


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

Re: Start a Veeam job from another machine

Veeam Logoby electricd7 » Fri Jun 20, 2014 12:31 pm

Thanks for the advice, but I get the same error. Here is the script I am running to test now:

Code: Select all
$backupserver = "veeam1.fqdn.org"
$username = "apollo\ckillion"
$password = convertto-securestring -string "p@ssword1" -asplaintext -force
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $Username, $Password
$session = New-PSSession $backupserver #-authentication CredSSP -Credential $credentials
invoke-command -session $session -scriptblock {Add-PSSnapin -Name VeeamPSSnapIn} 
Remove-PSSession $session


And the output from console:
PS C:\Users\ckillion\desktop> .\test.ps1
Cannot load Windows PowerShell snap-in VeeamPSSnapIn because of the following error: Could not load file or assembly
'file:///C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.PowerShell.dll' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
+ CategoryInfo : InvalidData: (VeeamPSSnapIn:String) [Add-PSSnapin], PSSnapInException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
+ PSComputerName : veeam1.fqdn.org
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

Re: Start a Veeam job from another machine

Veeam Logoby v.Eremin » Fri Jun 20, 2014 1:33 pm

If try to run Veeam snapin locally on backup server, will you have the same errors or not? What PS version is installed on backup server? Have you already checked this topic? Thanks.
v.Eremin
Veeam Software
 
Posts: 13293
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start a Veeam job from another machine

Veeam Logoby electricd7 » Fri Jun 20, 2014 1:44 pm

Yes, snapin works great on local Veeam server. Local veeam server is running PowerShell version 2, remote machine was running version 2 until I read the link you just posted yesterday. I then upgraded it to version 3 in an attempt to solve the issue and ran the Install-Veeam script as well. Still get same error after completing those steps. I tried on a second guest as well and get the same error when running remote powershell from there as well.
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

Re: Start a Veeam job from another machine

Veeam Logoby electricd7 » Fri Jun 20, 2014 6:38 pm

I have worked around this problem by scheduling the script I want to run as a scheduled task on the Veeam server with no trigger, and then just call the task from the remote machine via powershell. It works but its sloppy.
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

Re: Start a Veeam job from another machine

Veeam Logoby v.Eremin » Mon Jun 23, 2014 9:25 am

I'm running out of ideas. What OS the backup server and remote machine are using? In OS starting from Windows 2008, there are two PS - 32 and 64 bit. In the remote session you can try to load one or another and see whether it helps or not. Thanks.
v.Eremin
Veeam Software
 
Posts: 13293
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] : Adding VeeamPSSnapin in a remote powershell fails

Veeam Logoby vbogda » Thu Jan 15, 2015 10:41 am

Hi All,

I've searched the interwebs long and hard but I can't find a solution to this problem. When I try to load the VeeamPSSnapin through a remote Powershell session I get the following error:

Code: Select all
Add-PSSnapin : Cannot load Windows PowerShell snap-in VeeamPSSnapIn because of the following error: Could not load file or assembly 'file:///C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.PowerShell.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
    + CategoryInfo          : InvalidData: (VeeamPSSnapIn:String) [Add-PSSnapin], PSSnapInException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand


The error doesn't make sense because I'm remote Powershelling from an identical system. I get the error even when I remote powershell to localhost. I am beginning to think that it's some sort of a Win2K8 R2/Powershell combination bug.

Regards
vbogda
vbogda
Novice
 
Posts: 8
Liked: never
Joined: Thu Dec 11, 2014 2:19 pm
Full Name: Val Bogda

Re: Start a Veeam job from another machine

Veeam Logoby v.Eremin » Thu Jan 15, 2015 11:06 am

Hi,

Kindly, check suggestions provided above and see whether it makes any difference.

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

Re: Start a Veeam job from another machine

Veeam Logoby pinkerton » Mon Feb 23, 2015 3:36 pm

I just ran into the same issue and found the solution here:

http://richiban.uk/2012/08/23/ensuring- ... owershell/

After creating the files c:\windows\System32\wsmprovhost.exe.config and c:\windows\SysWOW64\wsmprovhost.exe.config with the following content, everything worked fine:

Code: Select all
<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
         <supportedRuntime version="v4.0.30319"/>       
         <supportedRuntime version="v2.0.50727"/>       
    </startup>
</configuration>
pinkerton
Enthusiast
 
Posts: 62
Liked: 4 times
Joined: Thu Sep 29, 2011 9:57 am


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 10 guests