Functions/Private/Get-PSPuTTYRegistrySessions.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using namespace Microsoft.Win32

function Get-PSPuTTYRegistrySessions {
  <#
  .Synopsis
  Obtains a connection to the PuTTY registry key for the current user's hive.
  #>

  [CmdletBinding()]
  param (
  )

  $Command = $PSCmdlet.MyInvocation.MyCommand.Name
  $Module = $PSCmdlet.MyInvocation.MyCommand.Module

  ### Get the PuTTY registry path
  $SessionRegPath = '{0}\Sessions' -f $Module.PrivateData['PuTTYRegPath']

  ### Open the CurrentUser hive and the PuTTY subkey
  $RegCurrentUser = [RegistryKey]::OpenBaseKey([RegistryHive]::CurrentUser, [RegistryView]::Default)
  $RegCurrentUser.OpenSubKey($SessionRegPath, $true)
}