Posh-SSH
Posh-SSH copied to clipboard
Cannot process argument transformation on parameter 'ShellStream'. Cannot convert the "Renci.SshNet.ShellStream" value of type "Renci.SshNet.ShellStream" to type "Renci.SshNet.ShellStream".
While triggering Invoke-SSHStreamShellCommand
, I am getting Cannot convert the "Renci.SshNet.ShellStream" value of type "Renci.SshNet.ShellStream" to type "Renci.SshNet.ShellStream". Error on azure devops pipeline.
Script block
function remoteConnectEngine($secUsername, $VmPassword, $remoteMachine) {
$password = ConvertTo-SecureString $VmPassword -AsPlainText -Force;
$pscredential = New-Object -TypeName System.Management.Automation.PSCredential("$secUsername", $password);
removeExistingSession;
Write-Host "##[section] Get the current EPOCH time !!!"
Start-Sleep -Seconds 5;
$triggerJMeterTest = "bash ./startJMeterTest.sh";
foreach ($rm in $remoteMachine) {
$currentSessionID = New-SSHSession -ComputerName $rm -Credential $pscredential -Forcs;
$SSHStream = New-SSHShellStream -Index $currentSessionID.SessionId;
Invoke-SSHStreamShellCommand -ShellStream $SSHStream -Command $triggerJMeterTest;
}
Start-Sleep -Seconds 5;
removeExistingSession
}
function removeExistingSession {
$remove = Get-SSHSession
if ($null -eq $remove -or $remove -eq 0) {
Write-Host "##[section] No active past session present !!!"
}
else {
foreach ($existingSessionID in $remove.SessionId){
$removeTheSession = Remove-SSHSession -SessionId $existingSessionID
if($removeTheSession) {
continue;
}
else {
Write-Host "##[error] There is a problem with terminating the active session with ID" $removeTheSession
}
}
Write-Host "##[section] All active session terminated successfully!!!"
}
}
function startJMeterServer {
$loadAgentMachine = '<remote_machine_Name>'
$LoadAgentUserName = "<User_Name>";
$LoadAgentVMPassword = "<Password>";
remoteConnectEngine $LoadAgentUserName $LoadAgentVMPassword $vm_Machine
}
Error Details:
Invoke-SSHStreamShellCommand : Cannot process argument transformation on parameter 'ShellStream'. Cannot convert the
"Renci.SshNet.ShellStream" value of type "Renci.SshNet.ShellStream" to type "Renci.SshNet.ShellStream".
At E:\agent\_work\40\s\PerformanceEvaluation\testJMeter.ps1:81 char:73
+ ... ommand = Invoke-SSHStreamShellCommand -ShellStream $SSHStream -Comman ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-SSHStreamShellCommand], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Invoke-SSHStreamShellCommand
How to resolve this issue.
Only thing I can think off is that Force is not spelled correctly and a session is not created.
On Jan 18, 2022, at 10:54 AM, JYOTI PRAKASH MALLICK @.***> wrote:
-Forcs
... or there is sort of dll hell Posh-SSH is latest version or beta ?
In azure cloud shell?
Sent from my iPhone
On Jan 18, 2022, at 5:22 PM, Max Kozlov @.***> wrote:
... or there is sort of dll hell Posh-SSH is latest version or beta ?
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.
I had the same problem with Posh-SSH version 3.0.1. For me the solution was to manually delete Renci.SshNet folder from C:\Windows\Microsoft.NET\assembly\GAC_64
^ I've been running into this same issue for a while now. I even updated to 3.0.6 and am still having the same issue. I'm running the commands from a windows 2019 server. I was hopeful that Georgy-Sav's solution would work for me but it did not.
Edit! Actually, Georgy-Sav's solution did work for me with one modification! In my environments, i had to delete the Renci.SshNet folder from the GACMSIL folder (not the GAC_64 folder). I've deleted the Renci.SshNet folder from both locations.
@bbrown2008, I think this PS command could helped in your case:
[System.AppDomain]::CurrentDomain.GetAssemblies() | ? { $_.Location -like '*GAC*Renci.SshNet*' }
It shows locations of all Renci.SshNet dlls from all GAC locations after you import Posh-SSH module.
I had the same problem with Posh-SSH version 3.0.1. For me the solution was to manually delete Renci.SshNet folder from C:\Windows\Microsoft.NET\assembly\GAC_64
This worked for me! Thank you very much.