PowerShell script exchange
Post Reply
Diegasus
Novice
Posts: 3
Liked: never
Joined: May 25, 2012 11:54 am

Add-PSSnapin through SSH - InvalidArgument ?

Post by Diegasus »

Hello,
i'm trying to start PowerShell on the Veeam Server through SSH connection. This work but when i try to add the VeeamPSSnapIn i have some errors.

I have installed freeSSH (i'm testing with freeSSH, in the future the connection will be started from a Linux server) on the VeeamBackup Server. I open the SSH connection from my laptop , i can reach the Veeam Server and start powershell:

Code: Select all

C:\Windows\system32>cd C:\Users\Veeam
C:\Users\Veeam>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
Veeam@xxx.xxx.xxx.xxx's password:
PS C:\Users\Veeam>
The command Get-PSSnapin return a list of snapin. The VeeamPSSnapIn is not in the List, also i try to add the VeeamPSSnapIn:

Code: Select all

PS C:\Users\Veeam> Add-PSSnapin VeeamPSSnapIn
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version
2.
At line:1 char:13
+ Add-PSSnapin <<<<  VeeamPSSnapIn
    + CategoryInfo          : InvalidArgument: (VeeamPSSnapIn:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad
   dPSSnapinCommand

PS C:\Users\Veeam>
but i have an error.... InvalidArgument...

When i try on the Veeam Server (starting the cmd, then powershell, Add-PSSnapin..) it work...

Why when i try with SSH it don't work? Is something not correct loaded when i start powershell on the SSH connection?
Any idea?

I will search a solution, but if you have some feedback this will be appreciated :-)

Diego
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Add-PSSnapin through SSH - InvalidArgument ?

Post by Sethbartlett »

Are you logging in through SSH with an administrative account or the same account you installed Veeam with? Make sure your account is added to the local administrative group.
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.
Diegasus
Novice
Posts: 3
Liked: never
Joined: May 25, 2012 11:54 am

Re: Add-PSSnapin through SSH - InvalidArgument ?

Post by Diegasus »

Hi Sethbartlett,

yes i'm using a user "veeam" that is in the Administrators group and i'm logging in through ssh with this user.
This should not be the problem.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Add-PSSnapin through SSH - InvalidArgument ?

Post by Sethbartlett »

Try doing Remote Powershell locally from the veeam box and see if you run into the same issues or not.
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.
Diegasus
Novice
Posts: 3
Liked: never
Joined: May 25, 2012 11:54 am

Re: Add-PSSnapin through SSH - InvalidArgument ?

Post by Diegasus »

Hi,
i will now explane two case that i tested:
In the first case i login on the Veeam Server and i execute the command on the cmd prompt windows (NOT launching PowerShell from Veeam B&R Interface).
In the second case i will do the same but i start an SSH connection to the Veeam Server from a remote client.

Case1:
- LogIn to the server with the user "veeam" (the user is the installation user for veeam and is in the Administrators group)
- Start cmd prompt
- Start powershell

Code: Select all

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Veeam>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\Veeam>
- check which SnapIn are loaded

Code: Select all

PS C:\Users\Veeam> Get-PSSnapin

Name        : Microsoft.PowerShell.Diagnostics
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains Windows Eventing and Performance Counter cmdlets.

Name        : Microsoft.WSMan.Management
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains cmdlets (such as Get-WSManInstance and Set-WSManInstance) that a
              re used by the Windows PowerShell host to manage WSMan operations.

Name        : Microsoft.PowerShell.Core
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.

Name        : Microsoft.PowerShell.Utility
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains utility Cmdlets used to manipulate data.

Name        : Microsoft.PowerShell.Host
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains cmdlets (such as Start-Transcript and Stop-Transcript) that are
              provided for use with the Windows PowerShell console host.

Name        : Microsoft.PowerShell.Management
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains management cmdlets used to manage Windows components.

Name        : Microsoft.PowerShell.Security
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains cmdlets to manage Windows PowerShell security.

- check which SnapIn are registered

Code: Select all

PS C:\Users\Veeam> Get-PSSnapin -registered


Name        : SqlServerCmdletSnapin100
PSVersion   : 2.0
Description : This is a PowerShell snap-in that includes various SQL Server cmdlets.

Name        : SqlServerProviderSnapin100
PSVersion   : 2.0
Description : SQL Server Provider

Name        : VeeamPSSnapIn
PSVersion   : 2.0
Description : This is a PowerShell snap-in that includes the Veeam's cmdlet.

Now i see that "VeeamPSSnapIn" in already registered and i can load it.

Code: Select all

PS C:\Users\Veeam> Add-PSSnapin VeeamPSSnapIn
PS C:\Users\Veeam>
Now if i re-check the loaded SnapIns i find the new one

Code: Select all


...
...

Name        : Microsoft.PowerShell.Host
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains cmdlets (such as Start-Transcript and Stop-Transcript) that are
              provided for use with the Windows PowerShell console host.

Name        : Microsoft.PowerShell.Management
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains management cmdlets used to manage Windows components.

Name        : VeeamPSSnapIn
PSVersion   : 2.0
Description : This is a PowerShell snap-in that includes the Veeam's cmdlet.

Now when i try to run a VBR cmdlet, for example

Code: Select all

PS C:\Users\Veeam> Get-VBRJob
it work.

This case work as expected

Case2:

- login from my client to the Veeam Server through SSH:

Code: Select all

ssh Veeam@xxx.xxx.xxx.xxx

Code: Select all

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd C:\Users\Veeam
C:\Users\Veeam>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
$
PS C:\Users\Veeam>

- check which SnapIn are loaded
--> same result like "Case1"

- check which SnapIn are registered

Code: Select all

PS C:\Users\Veeam> Get-PSSnapin -registered
--> no output.

i try to register the VeeamPSSnapin:

Code: Select all

PS C:\Users\Veeam> set-alias installutil C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe
PS C:\Users\Veeam> installutil 'C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll'
	
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5420
Copyright (c) Microsoft Corporation.  All rights reserved.


Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll assembly's progress.
The file is located at C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.InstallLog.
Installing assembly 'C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll'.
Affected parameters are:
   assemblypath = C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll
   logfile = C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.InstallLog
   logtoconsole = 

The Install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file for the C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll assembly's progress.
The file is located at C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.InstallLog.
Committing assembly 'C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll'.
Affected parameters are:
   assemblypath = C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll
   logfile = C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.InstallLog
   logtoconsole = 

The Commit phase completed successfully.

The transacted install has completed.
In the log Veeam.Backup.PowerShell.InstallLog i found:

Code: Select all

Committing assembly 'C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll'.
Affected parameters are:
   assemblypath = C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.dll
   logfile = C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.PowerShell.InstallLog
   logtoconsole = 
I try Get-PSSnapin -registered return no output... and no VBR cmdled work..

This was an update about my problem.
I will try something other.

@Sethbartlett: Remote PS will i try later, thank you

Regards
Diego
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests