A friend of mine found this enormously useful, one of the things PowerShell can do easily that is (apparently) helpful for people who want nothing to do with it otherwise (where it may be either PowerShell or Windows).

PuTTY stores session settings in the Registry, this little snippet using the PowerShell Registry Provider to update PuTTY session values. Anything goes as long as you can figure out the registry value you want to change.

Everything is in short-hand to make it, well, short. So, for reference this is what the shorthand really means:

  • ls is Get-ChildItem
  • sp is Set-ItemProperty
  • % is ForEach-Object (a loop operator)

List all sessions

List some sessions

More complex filtering can be performed using Where-Object (?), but that breaks the simplicity I’m striving for here.

The items returned by ls (Get-ChildItem) can be piped directly into sp (Set-ItemProperty) to change things.

Set the console size

Set a proxy

Add a username

This assumes none of the sessions have a username yet, if it were to run against a session with a username it would double up. That is, me@host becomes me@me@host.

Replace a username

Swapping out root@ with me@, a regular expression matches ^root at the beginning of the HostName. If the session does not use root nothing will change.

Leave a Reply

Your email address will not be published. Required fields are marked *