HI Lucd,
If i manually enable SSH and run the below script to verify the SLP status, SSH gets disabled. So it's not able open new SSH session
$cmdsub1 = @'
/etc/init.d/slpd status;
'@
$cmdsub2 = @'
chkconfig --list | grep slpd;
'@
$secPswd = ConvertTo-SecureString -String $pswd -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($user, $secPswd)
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
Get-VMHostService -VMHost $esx | Where-Object { $_.Key -eq 'TSM-SSH' } | Start-VMHostService -Confirm:$false | Out-Null
$session = New-SSHSession -ComputerName $esx.Name -Credential $cred -AcceptKey
$current = Invoke-SSHCommand -SSHSession $session -Command $cmdSub1
$persistent = Invoke-SSHCommand -SSHSession $session -Command $cmdSub2
New-Object -TypeName PSObject -Property ([ordered]@{
VMHost = $esx.Name
Current = $current.Output[0]
Persistent = $persistent.Output[0]
})
Remove-SSHSession -SSHSession $session | Out-Null
Get-VMHostService -VMHost $esx | Where-Object { $_.Key -eq 'TSM-SSH' } | Stop-VMHostService -Confirm:$false | Out-Null
}
Regards,
Kumar