Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-SSHStreamShellCommand is hanging. #594

Open
SunsparcSolaris opened this issue Sep 20, 2024 · 3 comments
Open

Invoke-SSHStreamShellCommand is hanging. #594

SunsparcSolaris opened this issue Sep 20, 2024 · 3 comments

Comments

@SunsparcSolaris
Copy link

Using this module to capture and back up running configs on various HP/Aruba network switches. It runs fine under my account, but when I change over to using the service account that is running it as a scheduled task, the Invoke step hangs indefinitely.

$formattedDate = get-date -format 'yyyyMMdd'
$backupPath = "tftp <IP-ADDRESS>"
$configFile = $switch + ".txt"
$logFile = "C:\TFTP\Logs\"+$switch+"_"+$formattedDate+".log" 
$connection = New-SSHSession -ComputerName $switch -Credential $Cred -AcceptKey:$True -ErrorAction Stop -ConnectionTimeout 120
$session = Get-SSHSession -ComputerName $switch
$stream = New-SSHShellStream -Index $session.sessionid -TerminalName "dumb"
$sshCommand = @"
A
en
<OPERATORUSERNAME>
<OPERATORPASSWORD>
copy startup-config $backupPath $configFile 
Logout
Y
Y
"@
$streamoutput = Invoke-SSHStreamShellCommand -ShellStream $stream -Command $sshCommand -Timeout 10
((($streamoutput -replace '\x1b\[[0-9;]*[a-z]', '').replace("�[?25h","")).replace("�[?6l�[?7h","")).replace("�[?25l","") | out-string | Out-File $logFile

Both accounts have the same permissions on the computer running the script and on the switch being backed up. I don't get any sort of output, just hangs.

@darkoperator
Copy link
Owner

darkoperator commented Sep 20, 2024 via email

@SunsparcSolaris
Copy link
Author

When running as a schedule task I would proba use an iStore for the fingerprints since there is not user folder. But you say it hangs on execution .. in that case to be honest no clue.

I set a timeout of 10 seconds on the command and it does indeed time out. It says "returning output collected so far", but it's all blank except for a single line that's not even relevant to the command I'm running.

It's also stopped running fine under my account also, hangs at the first switch in the loop and returns the above.

@darkoperator
Copy link
Owner

darkoperator commented Oct 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants