{"id":7848,"date":"2020-11-09T14:30:36","date_gmt":"2020-11-09T19:30:36","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7848"},"modified":"2020-11-11T11:58:40","modified_gmt":"2020-11-11T16:58:40","slug":"parsing-ssh-known-hosts-with-powershell-and-regular-expressions","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/","title":{"rendered":"Parsing ssh Known Hosts with PowerShell and Regular Expressions"},"content":{"rendered":"\n<p>Lately, I've been spending time learning more about ssh. Sadly, I've rarely had a need to learn and use ssh. But of course, with PowerShell 7 and ssh-based remoting, it is time to up my game. I've started deploying the ssh server component to my Windows test servers (I'll write about that another day) and exploring how to use ssh in my automation and scripting work. <\/p>\n\n\n\n<p>During recent testing, I tried to connect to a remote host where I had re-installed ssh. This resulted in a security warning that the thumbprints didn't match the current known host entry. Thus, I finally got around to learning where remote host configuration is stored. (I freely admit there's more that I don't know about ssh than what I do.) The ssh client stores remote host information in a text file in the .ssh directory which is in the root of the user's home folder. You can reference this file as ~\\.ssh\\known_hosts.<\/p>\n\n\n\n<p>If you open the file in a text editor you'll see something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">localhost ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGCbSDjrVNB\/oGITy7qKovJam+k2HKYCtJzyiYTjevW\/mYIF5umy\/1eOG7Nb2AtNgpI0p6ahZtChttdT\/hcZfAU=\n192.168.3.199 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOZuPhlOpxsbkWNT2YKr4OgjSz05B0CYfHbmPlFeshOVo3r5GaXDZ+N5aRfbbPf6VYqMK\/XPgO7VQ2rNcHdAxOw=\n192.168.3.200 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOmQ3X0Xa74ntBTAbTwCK64ZkQqkU2q0xBNWAp00xAMbSNwAvWMxysq6zWkHUx0\/+yS\/Rewxs8vjiHpzhuf+f5A=<\/code><\/pre>\n\n\n\n<p>This is content from the file on my Windows 10 desktop. On some clients, you might see the content in this form:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">|1|p+R0sPINIOBsfxHaXM42p+ndtJY=|6TxeZvVc26Emf4yLsKnLJjdxd2w= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBO5YNHNaeOKpLorx4BqqXRBr\/kK2+ZEd1OKHMSmozLLt7yS4hEHVG5Dg71qBVHZiE1dIUxeMmNEgexix4Odj\/hM=\n|1|0yLDq\/BJ0VCDcNlshrO5ngGMLOQ=|hhWDD\/C5KvfhpYzA+6q6XgEgMMA= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHswks7\/UNgwKica\/vF0cswPYoEVuMznbLKXLRXs+WWAULXZeEcUEgHm5NDeHGs+oU+7UeIoQ8xjiwl8T7MF\/iw=<\/code><\/pre>\n\n\n\n<p>In your ssh_config file, there is a setting called <em>HashKnownHosts<\/em>. On my Windows system, this is set to know so the host information is stored in plain text. Otherwise, you get a hashed entry in known_hosts and there's no way to reverse the process. Keep this in mind as I continue. <\/p>\n\n\n\n<p>After a little research, I learned that there is a structure to the known_hosts file. Unfortunately, it isn't as simple as a space-delimited file. Although you could try this on your file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$known = \"~\\.ssh\\known_hosts\"\nImport-CSV $known -Delimiter \" \" -Header \"Hostname\",\"Keytype\",\"Thumbprint\"<\/code><\/pre>\n\n\n\n<p>However, you might get results like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"351\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-1024x351.png\" alt=\"\" class=\"wp-image-7850\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-1024x351.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-300x103.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-768x263.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-1536x526.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-850x291.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1.png 1935w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In my case, I had entries with ports, hostnames with square brackets,  and some entries with an optional IP address. But no matter. If I know the structure I can parse each entry using regular expressions and create a custom object. And that's what I did.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Named Regular Expression Captures<\/h2>\n\n\n\n<p>To simplify the process (honestly!), I worked out a regular expression pattern that uses named captures.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">[regex]$rx = \"^(?&lt;host>^\\S+?)((?=:))?((?&lt;=:)(?&lt;port>\\d+))?(,(?&lt;address>\\S+))?\\s(?&lt;type>[\\w-]+)\\s(?&lt;thumbprint>.*)\"<\/code><\/pre>\n\n\n\n<p>The pattern starts by defining a named capture called <em>host <\/em>that matches on a group of non-whitespace characters, but using a less greedy match. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">^(?&lt;host>^\\S+?)<\/code><\/pre>\n\n\n\n<p>This pattern <em>might <\/em>be followed by a colon. This is a positive look-ahead.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">((?=:)<\/code><\/pre>\n\n\n\n<p>The second capture is one for the port, which might be optional. I'm looking for a group of numbers that are preceded by a colon. This is a look-behind. And this whole capture is options.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">((?&lt;=:)(?&lt;port>\\d+))?<\/code><\/pre>\n\n\n\n<p>Likewise, there might be an IP address preceded by a comma.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">(,(?&lt;address>\\S+))?<\/code><\/pre>\n\n\n\n<p>Then I know there should a white space (\\s) followed by the thumbprint type which I'm defining as any word character and the dash.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">(?&lt;type>[\\w-]+)<\/code><\/pre>\n\n\n\n<p>There's another space (\\s) and the rest should be the thumbprint.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">(?&lt;thumbprint>.*)<\/code><\/pre>\n\n\n\n<p>To process the text file, I found it easiest to turn it into an array of strings.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$content = (Get-Content -Path $known) -split \"`n\"<\/code><\/pre>\n\n\n\n<p>Now I can try my regex pattern on each entry.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"459\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-match-1024x459.png\" alt=\"\" class=\"wp-image-7852\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-match-1024x459.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-match-300x135.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-match-768x345.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-match-850x381.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-match.png 1226w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Each named capture is a group.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-group-1024x541.png\" alt=\"\" class=\"wp-image-7853\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-group-1024x541.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-group-300x158.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-group-768x406.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-group-850x449.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/know_hosts-group.png 1227w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I can easily get each named capture like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$matched.groups[\"host\"].value -replace \":$|\\[|\\]\", \"\"<\/code><\/pre>\n\n\n\n<p>For the host, I'm replacing square brackets and any trailing colons, with nothing. There is probably a way to do this with the regular expression capture, but it is complicated enough and a little extra step like this is no big deal. I can use this technique to construct a custom object.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">[pscustomobject]@{\n PSTypeName = \"sshKnownHost\"\n Hostname   = $sshHost\n Port       = $matched.groups[\"port\"].value\n Address    = $IP\n Keytype    = $matched.groups[\"type\"].value\n Thumbprint = $matched.groups[\"thumbprint\"].value\n }<\/code><\/pre>\n\n\n\n<p>I've defined a type name for the custom object called <em>sshKnownHost<\/em>. I did this so that if I wanted to, I could create custom format or type extensions.<\/p>\n\n\n\n<p>Here's the complete function, which you can find as a <a href=\"https:\/\/gist.github.com\/jdhitsolutions\/4f72822fd1f7fbad73295cb216e3de83\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">gist on GitHub<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">#requires -version 5.1\n\nFunction Get-sshKnownHost {\n&lt;#\n.Synopsis\nParse ssh known hosts\n.Description\nThis command will parse the ssh known_hosts file and write custom objects to\nthe pipeline. If HashKnownHosts is set to yes in ssh_config, you may not get\nmeaningful results.\n.Parameter Hostname\nSpecify a hostname. Wildcards are permitted. Leave blank to see all known\nssh hosts.\n.Example\nPS C:\\> Get-sshKnownHost\n\nHostname   : localhost\nPort       :\nAddress    :\nKeytype    : ecdsa-sha2-nistp256\nThumbprint : AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGCbSDjrVN\n             B\/oGITy7qKovJam+k2HKYCtJzyiYTjevW\/mYIF5umy\/1eOG7Nb2AtNgpI0p6ah\n             ZtChttdT\/hcZfAU=\n\nHostname   : 192.168.3.199\nPort       :\nAddress    :\nKeytype    : ecdsa-sha2-nistp256\nThumbprint : AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOZuPhlOpx\n             sbkWNT2YKr4OgjSz05B0CYfHbmPlFeshOVo3r5GaXDZ+N5aRfbbPf6VYqMK\/XP\n             gO7VQ2rNcHdAxOw=\n\n...\n.Example\nPS C:\\> Get-KnownHost -hostname srv*\n\nHostname   : srv1\nPort       :\nAddress    : 192.168.3.50\nKeytype    : ecdsa-sha2-nistp256\nThumbprint : AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBP6unwvoWX\n             AbQ2ymqO3\/TB2zSBayXP1ke2J+YxxOe57WoJ9ZEWdDyNdXwjYPzO139eVa8gFz\n             gPSV4DgDm\/hLfYM=\n\nHostname   : srv2\nPort       :\nAddress    : 192.168.3.51\nKeytype    : ecdsa-sha2-nistp256\nThumbprint : AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKcUMuWoDN\n             oM0RojPT+p\/z8F2N7pPychlc49oTvCsGH5urCaTu6R4Fu9tctxLvuPKRIpl08+\n             DRTnXOGI3m\/wDbw=\n\n\n.Notes\nLearn more about PowerShell: http:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/\n.Link\nssh-keygen\n.Inputs\nnone\n.Outputs\nsshKnownHost\n#>\n    [cmdletbinding()]\n    [alias(\"gkh\")]\n    [Outputtype(\"sshKnownHost\")]\n    Param(\n        [Parameter(Position = 0, HelpMessage = \"Specify a hostname. Wildcards are permitted. Leave blank to see all known hosts.\")]\n        [string]$Hostname\n    )\n\n    Write-Verbose \"Starting $($MyInvocation.MyCommand)\"\n    #define a list to hold host data\n    $data = [System.Collections.Generic.list[object]]::New()\n    [regex]$rx = \"^(?&lt;host>^\\S+?)((?=:))?((?&lt;=:)(?&lt;port>\\d+))?(,(?&lt;address>\\S+))?\\s(?&lt;type>[\\w-]+)\\s(?&lt;thumbprint>.*)\"\n    $known = \"~\\.ssh\\known_hosts\"\n    Write-Verbose \"Testing for $known\"\n    if (Test-Path $known) {\n        $content = (Get-Content -Path $known) -split \"`n\"\n        Write-Verbose \"Found $($content.count) entries\"\n\n        #process all entries even if searching for a single hostname because there\n        #might be multiple entries\n        foreach ($entry in $content) {\n            $matched = $rx.Match($entry)\n            $sshHost = $matched.groups[\"host\"].value -replace \":$|\\[|\\]\", \"\"\n            $IP = $matched.groups[\"address\"].value -replace \"\\[|\\]\", \"\"\n            Write-Verbose \"Processing $sshHost\"\n            #regex named captures are case-sensitive\n            #I haven't perfected the regex capture so I'll manually trim and trailing : in the hostname capture\n            $obj = [pscustomobject]@{\n                PSTypeName = \"sshKnownHost\"\n                Hostname   = $sshHost\n                Port       = $matched.groups[\"port\"].value\n                Address    = $IP\n                Keytype    = $matched.groups[\"type\"].value\n                Thumbprint = $matched.groups[\"thumbprint\"].value\n            }\n            #add each new object to the list\n            $data.Add($obj)\n        } #foreach entry\n    }\n    else {\n        Write-Warning \"Can't find $known. Is the ssh client installed?\"\n    }\n\n    if ($Hostname -AND $data.count -gt 0) {\n        Write-Verbose \"Searching for $hostname\"\n        $data.where({$_.hostname -like $hostname})\n    }\n    elseif ($data.count -gt 0) {\n        $data\n    }\n    Write-Verbose \"Ending $($MyInvocation.MyCommand)\"\n} #close function<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"276\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-1-1024x276.png\" alt=\"\" class=\"wp-image-7855\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-1-1024x276.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-1-300x81.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-1-768x207.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-1-1536x413.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-1-2048x551.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-1-850x229.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This still works with hashed entries.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"163\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-2-1024x163.png\" alt=\"\" class=\"wp-image-7856\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-2-1024x163.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-2-300x48.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-2-768x123.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-2-1536x245.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-2-850x136.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-2.png 1992w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The last entry is in plain text because I changed the config file. But now I have a PowerShell tool that I can easily use from the console.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"956\" height=\"260\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-3.png\" alt=\"\" class=\"wp-image-7857\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-3.png 956w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-3-300x82.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-3-768x209.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-knownhost-3-850x231.png 850w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>I am under no illusions that this is the best way to my goal. I also know that it is likely possible to construct an alternate regex pattern. But I know that working on this built-up my regex muscles, and the end result is a PowerShell tool that fills a need. PowerShell is all about objects in the pipeline. Ideally, you don't want to be parsing text, except when you need to parse text to create objects, as I've done with this function.<\/p>\n\n\n\n<p>If you're using ssh, I hope you'll give the function and try and let me know how it works out for you. Other questions or comments about what I did or why are welcome as usual.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lately, I&#8217;ve been spending time learning more about ssh. Sadly, I&#8217;ve rarely had a need to learn and use ssh. But of course, with PowerShell 7 and ssh-based remoting, it is time to up my game. I&#8217;ve started deploying the ssh server component to my Windows test servers (I&#8217;ll write about that another day) and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Parsing ssh Known Hosts with #PowerShell and Regular Expressions","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[224,534,502,613],"class_list":["post-7848","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-function","tag-powershell","tag-regular-expression","tag-ssh"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Parsing ssh Known Hosts with PowerShell and Regular Expressions &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here&#039;s how I took the text based list of known ssh hosts and turned them into objects that I can use at a PowerShell prompt.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Parsing ssh Known Hosts with PowerShell and Regular Expressions &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s how I took the text based list of known ssh hosts and turned them into objects that I can use at a PowerShell prompt.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-09T19:30:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-11T16:58:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-1024x351.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Parsing ssh Known Hosts with PowerShell and Regular Expressions\",\"datePublished\":\"2020-11-09T19:30:36+00:00\",\"dateModified\":\"2020-11-11T16:58:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/\"},\"wordCount\":791,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/known_hosts-as-csv-1-1024x351.png\",\"keywords\":[\"Function\",\"PowerShell\",\"Regular Expression\",\"SSH\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/\",\"name\":\"Parsing ssh Known Hosts with PowerShell and Regular Expressions &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/known_hosts-as-csv-1-1024x351.png\",\"datePublished\":\"2020-11-09T19:30:36+00:00\",\"dateModified\":\"2020-11-11T16:58:40+00:00\",\"description\":\"Here's how I took the text based list of known ssh hosts and turned them into objects that I can use at a PowerShell prompt.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/known_hosts-as-csv-1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/known_hosts-as-csv-1.png\",\"width\":1935,\"height\":663},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7848\\\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Parsing ssh Known Hosts with PowerShell and Regular Expressions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Parsing ssh Known Hosts with PowerShell and Regular Expressions &#8226; The Lonely Administrator","description":"Here's how I took the text based list of known ssh hosts and turned them into objects that I can use at a PowerShell prompt.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/","og_locale":"en_US","og_type":"article","og_title":"Parsing ssh Known Hosts with PowerShell and Regular Expressions &#8226; The Lonely Administrator","og_description":"Here's how I took the text based list of known ssh hosts and turned them into objects that I can use at a PowerShell prompt.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-11-09T19:30:36+00:00","article_modified_time":"2020-11-11T16:58:40+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-1024x351.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Parsing ssh Known Hosts with PowerShell and Regular Expressions","datePublished":"2020-11-09T19:30:36+00:00","dateModified":"2020-11-11T16:58:40+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/"},"wordCount":791,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-1024x351.png","keywords":["Function","PowerShell","Regular Expression","SSH"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/","name":"Parsing ssh Known Hosts with PowerShell and Regular Expressions &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1-1024x351.png","datePublished":"2020-11-09T19:30:36+00:00","dateModified":"2020-11-11T16:58:40+00:00","description":"Here's how I took the text based list of known ssh hosts and turned them into objects that I can use at a PowerShell prompt.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/known_hosts-as-csv-1.png","width":1935,"height":663},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7848\/parsing-ssh-known-hosts-with-powershell-and-regular-expressions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Parsing ssh Known Hosts with PowerShell and Regular Expressions"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":7969,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/","url_meta":{"origin":7848,"position":0},"title":"Deploy OpenSSH Server to Windows 10","author":"Jeffery Hicks","date":"December 16, 2020","format":false,"excerpt":"PowerShell 7 offers a number of compelling reasons to adopt it. One of the best is support for SSH as a PowerShell remoting protocol. Unfortunately, this is not a topic that typically comes up for Windows-centric IT Pros. I know this is definitely true in my case, and a deficiency\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":7978,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7978\/deploy-openssh-to-windows-server\/","url_meta":{"origin":7848,"position":1},"title":"Deploy OpenSSH to Windows Server","author":"Jeffery Hicks","date":"December 17, 2020","format":false,"excerpt":"Yesterday I shared some PowerShell ideas for remotely setting up the server component of ssh on a remote Windows 10 system. This would allow you to establish an ssh session to the desktop or even use PowerShell remoting over ssh. Next, we need to look at doing the same thing\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":8482,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8482\/revisiting-powershell-version-inventory\/","url_meta":{"origin":7848,"position":2},"title":"Revisiting PowerShell Version Inventory","author":"Jeffery Hicks","date":"July 13, 2021","format":false,"excerpt":"In the past, I've shared a variety of PowerShell approaches that you can use to inventory what versions of PowerShell are installed. But I think I now have the best approach short of searching the hard drive for powershell.exe and pwsh.exe, which I suppose is still a possibility and something\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/get-psinstalled-4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/get-psinstalled-4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/get-psinstalled-4.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/get-psinstalled-4.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":7257,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7257\/cross-platform-powershell-profiles-with-windows-terminal\/","url_meta":{"origin":7848,"position":3},"title":"Cross Platform PowerShell Profiles with Windows Terminal","author":"Jeffery Hicks","date":"February 13, 2020","format":false,"excerpt":"Earlier this week I shared my techniques for creating a Windows Terminal profile that would open a remote PowerShell session. But with PowerShell 7, I can also connect to non-Windows machines using SSH. So why not extend my code to allow connecting to a Linux box? Before you try anything\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5895,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5895\/another-look-at-powershell-core-version-information\/","url_meta":{"origin":7848,"position":4},"title":"Another Look at PowerShell Core Version Information","author":"Jeffery Hicks","date":"February 8, 2018","format":false,"excerpt":"As PowerShell Core begins to spread into our world, and as we start thinking about working and scripting cross-platform, it will be useful to know what type of platform you are running on. The built in $PSVersionTable is an obvious place to start. On PowerShell Core there are also some\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-5.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-5.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-5.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":8492,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8492\/searching-for-powershell-with-cim\/","url_meta":{"origin":7848,"position":5},"title":"Searching for PowerShell with CIM","author":"Jeffery Hicks","date":"July 15, 2021","format":false,"excerpt":"Yesterday I shared a script that you could use to inventory systems for Windows PowerShell and PowerShell 7 installations. This should work for most people who install PowerShell 7 with the provided installer. But, as has been pointed out more than once to me, this won't detect any side-loaded or\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=7848"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7848\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}