Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

powershell ssh with password

$Password = "Password"
$User = "UserName"
$ComputerName = "Destination"
$Command = "SSH Command"

$secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential($User, $secpasswd)

$SessionID = New-SSHSession -ComputerName $ComputerName -Credential $Credentials #Connect Over SSH

Invoke-SSHCommand -Index $sessionid.sessionid -Command $Command # Invoke Command Over SSH
 
PREVIOUS NEXT
Tagged: #powershell #ssh #password
ADD COMMENT
Topic
Name
7+9 =