Created
November 29, 2012 10:26
-
-
Save xoner/4168058 to your computer and use it in GitHub Desktop.
Simple function to load putty inside Conemu hosted powershell given a hostname or a saved session name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pssh() | |
{ | |
Param | |
( | |
[Parameter(Mandatory=$true)] | |
[String] | |
$destinationHost = $null | |
) | |
if($host -ne $null) | |
{ | |
# Check if exists a saved session with the given destination, | |
# If it doesn't exists try a direct ssh connection to the destination | |
if(Test-Path "HKCU:\Software\SimonTatham\PuTTY\Sessions\$destinationHost") | |
{ | |
iex "putty -new_console -load $destinationHost" | |
} | |
else | |
{ | |
iex "putty -new_console -ssh $destinationHost" | |
} | |
} | |
else | |
{ | |
Write-Host -Foregroud-Color red "A host name or saved session name must be provided" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment