Powershell VSP enable/disable port

  • 7 April 2021
  • 4 replies


I search how to configure port (example: enable/disable) on VSP 8400  with Powershell 
No probleme on X440 (EXOS)  with SSHCommand but don’t work on VSP 
The connection seems good but the orders (Invoke-SSHCommand) are blocked for few seconds, and after connection lost

Can you hlep me ? 


4 replies

Userlevel 4

thanks for sharing

Juste for information, it’s perfectible but it’s working  like this:


#install module
#Install-Module -Name Posh-SSH -force

#create username/pw
$userName = "admin"
$password = "password"

#create $cred as secure string using $username and $password
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr

#create ssh session to server that fired alert using $cred
$sessionSSH = New-SSHSession -ComputerName "switch_IP" -Credential $cred -AcceptKey

#set stream
$stream = $sessionSSH.session.CreateShellStream("PS-SSH", 0, 0, 0, 0, 1000)

#invokes stream to run command as sudo. gets pw from $secstr
$result = Invoke-SSHStreamExpectSecureAction -ShellStream $stream -command "enable" -ExpectString "10" -SecureAction $secstr
$result = Invoke-SSHStreamExpectSecureAction -ShellStream $stream -command "configure terminal" -ExpectString "10" -SecureAction $secstr
$result = Invoke-SSHStreamExpectSecureAction -ShellStream $stream -command "interface gigabitEthernet 3/15" -ExpectString "10" -SecureAction $secstr
$result = Invoke-SSHStreamExpectSecureAction -ShellStream $stream -command "shutdown" -ExpectString "10" -SecureAction $secstr


$id_session = Get-SSHSession 

Remove-SSHSession $id_session


ok I understand, I will test
Thank you for your prompt response.
have a good day.

Userlevel 5

I never used this Posh-SSH module, but reading its documentation here

it seems to me that Invoke-SSHCommand is sending the commands in a dedicated SSH channel within the SSH session; this is how SSH emulates the older rsh. But this mode will not work with VOSS. VOSS SSH server requires an interactive shell to be run inside the SSH channel.

So I think you will need to use the $session.Session.CreateShellStream approach from the same link above.