I have this script
$db = import-csv -Path ".\testdb.csv"
$inputID = Read-Host -Prompt "ID"
$entry = $db -match $inputID
Write-Host "IP:" $entry.IP
$User = "user"
$Password = "pass"
$User2 = "user2"
$Password2 = "pass2"
$Command = "C:\test.exe"
$secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential($User, $secpasswd)
$secpasswd2 = ConvertTo-SecureString $Password2 -AsPlainText -Force
$Credentials2 = New-Object System.Management.Automation.PSCredential($User2, $secpasswd2)
Get-SSHTrustedHost | Remove-SSHTrustedHost
try {
$SessionID = New-SSHSession -ComputerName $entry.IP -Credential $Credentials -AcceptKey:$true
}
catch {
$SessionID = New-SSHSession -ComputerName $entry.IP -Credential $Credentials2 -AcceptKey:$true
}
Is any chance to try connect with 2 different credentials ; if one fail try to other? So.. first time try user and password ; second time try user2 and password2
Thank you. :)