Remote PowerShell

PowerShell script exchange

Remote PowerShell

Veeam Logoby gvinpin » Mon May 16, 2011 9:17 pm

I can start remote PowerShell (2008R2) session, but specific Veeam commands will not run, as like extensions not installed.
Locally (on target server) I can run Veeam specific PowerShell commands.
Something missing?
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby Gostev » Mon May 16, 2011 11:57 pm

I know little about PowerShell, but I would check that you have PS 2.0 installed on both servers (since 1.0 does not support remote operations), and also if you have Veeam PS extensions installed on both. Thanks.
Gostev
Veeam Software
 
Posts: 21396
Liked: 2350 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Remote PowerShell

Veeam Logoby gvinpin » Tue May 17, 2011 12:49 am

OK, found import-psession to do it.

$s=new-pssession -computername xxxxx
import-pssession -session $s

But, when I am trying to run job called EV, using this command:

Start-VBRJob -Job EV

getting error message.
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby gvinpin » Tue May 17, 2011 6:29 am

Another update:
I need to run locally this script to start existing job called EV

$job=Get-VBRJob | where {$_.Name –eq “EV”}
Start-VBRJob –Job $job

But, I cannot run it remotely.

Basic idea is to trigger this job remotely as a part of a Symantec Enterprise Vault backup.
Anyone has any idea on how to do it?
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby Vitaliy S. » Tue May 17, 2011 8:32 am

Are you able to trigger the same script from a batch file locally on the backup server?
Vitaliy S.
Veeam Software
 
Posts: 19568
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Remote PowerShell

Veeam Logoby gvinpin » Tue May 17, 2011 8:57 am

Yes,
$job=Get-VBRJob | where {$_.Name –eq “EV”}
Start-VBRJob –Job $job

works fine locally on backup server.
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby gvinpin » Tue May 17, 2011 9:49 pm

Should I raise a support call?
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby Sethbartlett » Wed May 18, 2011 5:02 am

I'm guessing that when you are testing the commands locally, you are doing it within the Veeam Power shell console? It sounds like you need to do 1 of 2 things:

1. Run C:\Program Files\Veeam\Backup and Replication\Initialize-VeeamToolkit.ps1 to initialize the Veeam snap-in or
2. Run the command "Add-PSSnapin VeeamPSSnapIn" so you can use the Veeam powershell commands.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Remote PowerShell

Veeam Logoby gvinpin » Wed May 18, 2011 5:19 am

Sethbartlett wrote:I'm guessing that when you are testing the commands locally, you are doing it within the Veeam Power shell console? It sounds like you need to do 1 of 2 things:

1. Run C:\Program Files\Veeam\Backup and Replication\Initialize-VeeamToolkit.ps1 to initialize the Veeam snap-in or
2. Run the command "Add-PSSnapin VeeamPSSnapIn" so you can use the Veeam powershell commands.


I can use Veeam Powershell commands locally, no problems.
But, I cannot use it remotely from other computer.
I can create a PS remote session and use native PS commands, but this remote session do not recognise that backup server has VeeamPSSnapin installed.
I will try your commands anyway, thanks.
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby Alexey D. » Wed May 18, 2011 8:41 am

To use Veeam PowerShell remotely you should perform these steps:
- install WinRM service (Windows Remote Management);
- type this command in PS console:

Code: Select all
Enable-PSRemoting

Should work! Let us know if not.
Alexey D.
 

Re: Remote PowerShell

Veeam Logoby gvinpin » Wed May 18, 2011 9:36 pm

Alexey D. wrote:To use Veeam PowerShell remotely you should perform these steps:
- install WinRM service (Windows Remote Management);
- type this command in PS console:

Code: Select all
Enable-PSRemoting

Should work! Let us know if not.


I have already told several times, that I can connect remotely.
Please spend some time reading my posts.
The problem is that during remote session, I cannot run Veeam subset of cmdlets.
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby Sethbartlett » Thu May 19, 2011 2:05 am

After connecting remotely, are you doing the Add-PSSnapin VeeamPSSnapIn command? Does it give you an error stating that it doesn't exist or what? Your connection outside of the Veeam box would not know about the commands without being using the snapin first.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Remote PowerShell

Veeam Logoby gvinpin » Thu May 19, 2011 5:51 am

Sethbartlett wrote:After connecting remotely, are you doing the Add-PSSnapin VeeamPSSnapIn command? Does it give you an error stating that it doesn't exist or what? Your connection outside of the Veeam box would not know about the commands without being using the snapin first.


Thanks a lot, that was a missing part.

So, the final script to start existing job named EV from remote Powershell:

$s = New-PSSession -Computername server1
Enter-PSSession $s
Add-PSSnapin VeeamPSSnapIn
$job=Get-VBRJob | where {$_.Name –eq “EV”}
Start-VBRJob –Job $job
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Remote PowerShell

Veeam Logoby 1-0-1 » Wed May 02, 2012 3:25 pm

I noticed if I run the command manually it works but if I put it into Powershell script it stops after it connects to the remote server. My script looks like this:

Code: Select all
$s = New-PSSession -Computername srvveeam02.internal.com.na
Enter-PSSession $s
Add-PSSnapin VeeamPSSnapIn
Get-VBRJob | where {$_.Name -eq "P1DR"} | Start-VBRJob -RunAsync


So once I execute the script from the command line it just stops at the remote powershell prompt. So basically it seems to stop straight after:

Code: Select all
Enter-PSSession $s

If I execute the command one by hand it starts the remote backup job. The whole idea is that I have this script as part of a post backup command on one VEEAM Server to start the backups on another remote VEEAM Server. Cannot schedule the jobs so basically the last job on the local VEEAM server is going to start the next job on the remote VEEAM server.

I am using VEEAM Backup and Replication v5.0.2.230 (x64) on Windows 2008 R2 Standard Edition (x64) with Powershell 2.0.
1-0-1
Enthusiast
 
Posts: 54
Liked: never
Joined: Tue Nov 30, 2010 1:38 pm
Full Name: Bernd

Re: Remote PowerShell

Veeam Logoby ThomasMc » Wed May 02, 2012 3:29 pm 2 people like this post

try

Code: Select all
Invoke-Command -Session $s -ScriptBlock {
   Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
   Get-VBRJob | where {$_.Name -eq "P1DR"} | Start-VBRJob -RunAsync
}


or v6

Code: Select all
Invoke-Command -Session $s -ScriptBlock {
   Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
   Get-VBRJob -Name "P1DR" | Start-VBRJob -RunAsync
}


instead of entering the session


[Added]
Don't forget the housekeeping :)

Code: Select all
Get-PSSession | Remove-PSSession
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Next

Return to PowerShell



Who is online

Users browsing this forum: robbysmith and 5 guests