New-SSHSession : Sequence contains more than one element
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- powershell
- Domain
- cli
Research direction
Start with the supplied Adjust-gslb function and its New-SSHSession call, then inspect how the Posh-SSH command handles the PSCredential created by Get-Credential. Reproduce the reported error with the two NetScaler addresses and compare it with the hardcoded credential case. Done means the credential-passing behavior and the source of the multiple-element error are identified and covered by an appropriate regression check.
Written by the indexing model from the issue text.
Description
I am getting the below error when trying to use get-credential in my script and passing $creds to a function. If I hardcode nsuser and nspass in the script this works fine. Any help is much appreciated
New-SSHSession : Sequence contains more than one element At N:\scripts\Netscaler\Adjust-NS-GSLB\Adjust-NS-GSLB-v3.1.ps1:54 char:2 + New-SSHSession -computername $nsip -Credential $creds -acceptKey ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Renci.SshNet.SshClient:SshClient) [New-SSHSession], InvalidOperationException + FullyQualifiedErrorId : SSH.NewSshSessionHere is the script that I am using
#---------------------
Function Adjust-gslb {
[Parameter(Mandatory = $true)]
param (
$nsips = [string]$nsips,
$Creds = [string]$Creds,
$ns_cmd = [string]$nsremove
)
$Creds = New-Object System.Management.Automation.PSCredential ($nsuser, $nspass)
Write-Host "Adjust_GSLB Function - Adjusting $ns_cmd" -ForegroundColor cyan
foreach($nsip in $nsips){
Get-SSHSession | Remove-SSHSession | Out-Null
New-SSHSession -computername $nsip -Credential $creds -acceptKey | out-null
$temp2 = (Invoke-SSHCommand -index 0 -command "$ns_cmd")
}
remove-sshsession -index 0 | out-null
}
#----------------------
#Main Script
$nsips = "1962.168.2.52","192.168.54.25"
$nsremove = "bind gslb vserver stuff -servername MyStuff"
$mycred = Get-Credential -UserName $env:username -Message "Enter in your UID and PWD for the NS"
$nsuser = $mycred.username
$nspass = $mycred.password
$Creds = New-Object System.Management.Automation.PSCredential ($nsuser, $nspass)
Adjust-gslb -nsips $nsips -creds $Creds -ns_cmd $nsremove
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from darkoperator/Posh-SSH
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
darkoperator/Posh-SSH#626 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
darkoperator/Posh-SSH#625 · 5 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
darkoperator/Posh-SSH#623 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
darkoperator/Posh-SSH#621 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
darkoperator/Posh-SSH#617 · 2 comments ·
All issues in darkoperator/Posh-SSH
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
AvengeMedia/DankMaterialShell#3523 ·
-
comp/cli comp/cron P3 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
NousResearch/hermes-agent#117433 · 2 comments ·