PowerShell - SSH From windows

preview_player
Показать описание
(How to run a command on Linux/Unix/network device via ssh from windows)

In this video I demonstrate how you can connect to a SSH based device from a windows box and execute command remotely on them.
The script is very simple, though quite powerful.
I added the use of a simple input file in csv format, so you can run it against multiple systems if you like.

*powershell
*learn powershell
*automation
*learn automation
*windows
*linux
*windows powershell

Code :

#$PSVersionTable
#find-module posh-ssh
#install-module Posh-SSH
#get-module Posh-SSH #| select ExportedCommands
# $p = "MyPass01"
# $secpass = $p | ConvertTo-SecureString -AsPlainText -Force
# $clientCreds = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList "root", $secpass
# $o = Invoke-SSHCommand -SSHSession $SSHsession -Command "ls /"
# $o
# $o.Output #this is the output property you get back
# Remove-SSHSession -SSHSession $SSHsession | Out-Null

$o.Output #this is the output property you get back
Start-Sleep -Seconds 3
Remove-SSHSession -SSHSession $SSHsession | Out-Null
}
Рекомендации по теме
Комментарии
Автор

You should post some of this stuff in the PowerShell subreddit, you do have some very useful tips and that would be a perfect place to get more exposure. As for posh-ssh, it is extremely useful for Linux, Unix, BSD, etc. Your content is good, keep up the good work.

securedigitsplus
Автор

How to automate powershell itself using powershell?
Execute "ipconfig" command automatic

shalinipandit