PowerShell script exchange
Post Reply
electricd7
Expert
Posts: 121
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

Start a Veeam job from another machine

Post by electricd7 »

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: 121
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

Re: Start a Veeam job from another machine

Post by electricd7 »

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?
tsightler
VP, Product Management
Posts: 6009
Liked: 2842 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Start a Veeam job from another machine

Post by tsightler »

There are examples in the Getting Started and Code Examples section. Here's the link to a specific example.
electricd7
Expert
Posts: 121
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

Re: Start a Veeam job from another machine

Post by electricd7 »

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: 121
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

Re: Start a Veeam job from another machine

Post by electricd7 »

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.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start a Veeam job from another machine

Post by veremin »

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.
electricd7
Expert
Posts: 121
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

Re: Start a Veeam job from another machine

Post by electricd7 »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start a Veeam job from another machine

Post by veremin »

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.
electricd7
Expert
Posts: 121
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

Re: Start a Veeam job from another machine

Post by electricd7 »

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: 121
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

Re: Start a Veeam job from another machine

Post by electricd7 »

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.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start a Veeam job from another machine

Post by veremin »

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.
vbogda
Novice
Posts: 8
Liked: never
Joined: Dec 11, 2014 2:19 pm
Full Name: Val Bogda
Contact:

[MERGED] : Adding VeeamPSSnapin in a remote powershell fails

Post by vbogda »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start a Veeam job from another machine

Post by veremin »

Hi,

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

Thanks.
pinkerton
Enthusiast
Posts: 82
Liked: 4 times
Joined: Sep 29, 2011 9:57 am
Contact:

Re: Start a Veeam job from another machine

Post by pinkerton »

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>
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests