- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am unable to get the VM name from the invoke-sshcommand of a remote VM. Please help!!
$WPassword = "password123"
$pass = ConvertTo-SecureString -AsPlainText $WPassword -Force
$Creds = New-Object System.Management.Automation.PSCredential ("localhost\admin", $pass)
Invoke-Command -ComputerName WINJUMP01 -ScriptBlock {
$pass = ConvertTo-SecureString -AsPlainText "mypassword" -Force
$Cred = New-Object System.Management.Automation.PSCredential ("root", $pass)
$script = @"
echo "Checking VM Info of :: $(hostname)"
"@
$session = New-SSHSession -ComputerName "mylinuxvm" -Credential $Cred -AcceptKey
$result = Invoke-SSHCommand -SSHSession $session -Command $script -Verbose
Write-Output "VMInfo by on $($date) for Linux Server : $(hostname) `r`n" >> "D:\Date\output1.txt"
$result.output
Remove-SSHSession -SSHSession $session | Out-Null
} -credential $Creds