Disaster recovery orchestration for the Enterprise (formerly Veeam Availability Orchestrator)
Post Reply
andre.simard
Service Provider
Posts: 224
Liked: 24 times
Joined: Feb 05, 2016 8:07 pm
Contact:

Custom Script Step

Post by andre.simard »

Case #04341209
Hi,

I have a Powershell script that is using Posh-SSH module. The script is working fine when run manually. When run from VAO server, it is falling.

Look like the script when start from VAO is running in special shell and not able to access assembly.

Is there a way i can test the script the way VAO is starting it?

Error:
<18> Error [Powershell] [Event] SSH.NewSshSession
<18> Error [Powershell] [Event] The method or operation is not implemented. (System.NotImplementedException)
<18> Error [Powershell] [Event] at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
<18> Error [Powershell] [Event] at Renci.SshNet.Session.Connect()
<18> Error [Powershell] [Event] at Renci.SshNet.BaseClient.Connect()
<18> Error [Powershell] [Event] at SSH.NewSessionBase.ProcessRecord()



SCRIPT:
import-module Posh-SSH
Add-Type -Path "C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\2.2\Assembly\Renci.SshNet.dll"
$username = "VAO_user"
$AESKey = Get-Content D:\VAO_Script\AES_Interface.key
$pwdTxt = Get-Content D:\VAO_Script\Password_Interface.txt
$securePwd = $pwdTxt | ConvertTo-SecureString -Key $AESKey
$credObject = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securePwd
$session = New-SSHSession -ComputerName "10.10.10.10" -Credential $credObject
$interfaces=(Invoke-SSHCommand -index 0 -command "show interfaces").output | ? {$_ -match "bond1.4"}
foreach ($interface in $interfaces){
$command=Invoke-SSHCommand -Command "show interface $interface state" -SSHSession $session
if ($command.ExitStatus -eq 0)
{
if($command.Output -match "state off")
{
Write-host "$interface : Turn ON Please"
}
elseif ($command.Output -match "state on")
{
Write-host "$interface : Already ON"
}
}
}
Alec King
VP, Product Management
Posts: 1445
Liked: 362 times
Joined: Jan 01, 2006 1:01 am
Contact:

Re: Custom Script Step

Post by Alec King »

Hello,
We believe that the Posh-SSH module is loaded when the script runs in VAO, as we can see the call stack in the error message.
Probably the desktop PS environment where you test the script also loads other assemblies, which Posh-SSH depends on. But VAO doesn't load them.
Can you confirm which modules are loaded in the desktop environment, and explicitly load the same modules in the script?
andre.simard
Service Provider
Posts: 224
Liked: 24 times
Joined: Feb 05, 2016 8:07 pm
Contact:

Re: Custom Script Step

Post by andre.simard »

Hi,

Finally i found the issue.
Module should be install in the folder : C:\Windows\System32\WindowsPowerShell\v1.0\Modules and not into the default : C:\Program Files\WindowsPowerShell\Modules

Thank you
Alec King
VP, Product Management
Posts: 1445
Liked: 362 times
Joined: Jan 01, 2006 1:01 am
Contact:

Re: Custom Script Step

Post by Alec King »

OK Andre, thanks for the update. Glad it's working now!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest