{"id":3815,"date":"2014-04-22T09:42:17","date_gmt":"2014-04-22T13:42:17","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3815"},"modified":"2014-04-22T09:42:17","modified_gmt":"2014-04-22T13:42:17","slug":"get-remote-powershell-session-connections","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/","title":{"rendered":"Get Remote PowerShell Session Connections"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass-150x150.png\" alt=\"magnifying-glass\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-3539\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass-150x150.png 150w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass.png 288w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a> During a recent PowerShell training class we naturally covered PowerShell remoting. During the discussion I explained that a remote PSSession is essentially transparent to any currently logged on user. Unless of course you reboot the computer! One way you can identify a remote session is by the presence of the wsmprovhost process. You should see this process whenever there is a remote PSSession to the computer. So then the discussion turned to tracking who might have sessions across multiple computers which is especially helpful when dealing with disconnected sessions since you can only see your own sessions. I don't have a perfect solution, but let's see if this helps.  Here is Get-PSRemoteSession.<\/p>\n<pre class=\"lang:ps decode:true \" >#requires -version 3.0\r\n\r\nFunction Get-PSRemoteSession {\r\n\r\n&lt;#\r\n.SYNOPSIS\r\nGet remote PSSession processes.\r\n.DESCRIPTION\r\nThis command uses CIM to retrieve the wsmprovhost process that might be running\r\non a remote computer. You can use this information to determine how long a \r\nsession has been running and by what user. By default the command shows a \r\nsummary. If you want to see the full detail, use the -Full parameter. The\r\nprocess owner and runtime will be added to the object in either case.\r\n.PARAMETER Computername\r\nThis parameter has aliases of CN, Name and PSComputername\r\n.PARAMETER Full\r\nWrite the full process object to the pipeline instead of the summary.\r\n.EXAMPLE\r\nPS C:\\&gt; Get-PSRemoteSession lon-dc1\r\n\r\nProcessID      : 7016\r\nCreationDate   : 4\/3\/2014 1:25:32 PM\r\nRuntime        : 23:36:38.0799372\r\nOwner          : MYDOMAIN\\Jeff\r\nPSComputername : lon-dc1\r\n\r\nProcessID      : 4676\r\nCreationDate   : 4\/4\/2014 12:23:41 PM\r\nRuntime        : 00:38:28.9568735\r\nOwner          : MYDOMAIN\\Administrator\r\nPSComputername : lon-dc1\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; Get-PSRemoteSession lon-dc1 -full | select Owner,ProcessID,VM,WS,runtime\r\n\r\nOwner     : MYDOMAIN\\Jeff\r\nProcessID : 7016\r\nVM        : 163262464\r\nWS        : 44392448\r\nRuntime   : 23:47:39.0140240\r\n\r\nOwner     : MYDOMAIN\\Administrator\r\nProcessID : 4676\r\nVM        : 180445184\r\nWS        : 46551040\r\nRuntime   : 00:49:29.8899602\r\n\r\nGet full process information and select some key properties\r\n.EXAMPLE\r\nPS C:\\&gt; get-remotesession chi-dc04,chi-dc01 | Group Owner -NoElement\r\n\r\nCount Name                     \r\n----- ----                     \r\n    1 GLOBOMANTICS\\jeff        \r\n    2 GLOBOMANTICS\\Administr...\r\n\r\n\r\nDisplay what user accounts are using remote sessions on the specified computers.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; Get-Content c:\\work\\computers.txt | Get-PSRemoteSession | where {$_.Runtime -gt \"16:00:00\"}\r\n\r\nFor a list of computers, get remote PSSessions that have been running longer \r\nthan 16 hours.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; get-remotesession chi-dc04,chi-dc01,chi-app01 | sort PSComputername | format-table -GroupBy PSComputername -Property CreationDate,Runtime,Owner\r\n\r\n\r\n   PSComputerName: chi-app01\r\n\r\nCreationDate                 Runtime                     Owner                      \r\n------------                 -------                     -----                      \r\n4\/11\/2014 9:58:16 AM         00:04:29.8719959            GLOBOMANTICS\\Administrator \r\n\r\n\r\n   PSComputerName: chi-dc01\r\n\r\nCreationDate                 Runtime                     Owner                      \r\n------------                 -------                     -----                      \r\n4\/11\/2014 9:46:24 AM         00:16:21.2699348            GLOBOMANTICS\\Administrator \r\n\r\n\r\n   PSComputerName: chi-dc04\r\n\r\nCreationDate                 Runtime                     Owner                      \r\n------------                 -------                     -----                      \r\n4\/11\/2014 9:43:06 AM         00:19:36.8797428            GLOBOMANTICS\\jeff          \r\n4\/11\/2014 9:47:25 AM         00:15:18.0563043            GLOBOMANTICS\\Administrator \r\n\r\n.NOTES\r\nVersion       : 1.0\r\nLast Updated  : April 11, 2014\r\n\r\nLearn more:\r\n PowerShell in Depth: An Administrator's Guide (http:\/\/www.manning.com\/jones2\/)\r\n PowerShell Deep Dives (http:\/\/manning.com\/hicks\/)\r\n Learn PowerShell 3 in a Month of Lunches (http:\/\/manning.com\/jones3\/)\r\n Learn PowerShell Toolmaking in a Month of Lunches (http:\/\/manning.com\/jones4\/)\r\n \r\n\r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n.LINK\r\nGet-CimInstance\r\nabout_PSSessions\r\n#&gt;\r\n\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Position=0,\r\nValueFromPipeline=$True,\r\nValueFromPipelineByPropertyName=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"CN\",\"Name\",\"PSComputername\")]\r\n[string[]]$Computername,\r\n[switch]$Full\r\n)\r\n\r\nBegin {\r\n    Write-Verbose \"Starting Get-PSRemoteSession\"\r\n} #begin\r\n\r\nProcess {\r\nforeach ($computer in $computername) {\r\n    #test connection\r\n    Write-Verbose \"Testing if computer $computer is pingable\"\r\n\r\n    #do a single ping to verify computer is up\r\n    If (Test-Connection -ComputerName $computer -count 1 -Quiet) {\r\n\r\n        Write-Verbose \"Querying $computer\"\r\n        Try {\r\n            #use CIM to remotely query the computer\r\n            $data = Get-CimInstance win32_process -filter \"name='wsmprovhost.exe'\" `\r\n            -ComputerName $computer -ErrorAction Stop -ErrorVariable MyErr\r\n\r\n            if ($data) {\r\n                Write-verbose \"Found sessions on $computer\"\r\n                Write-verbose ($data[0] | out-string)\r\n\r\n                #add some custom properties\r\n                $data | Add-Member -membertype ScriptProperty -Name Runtime -value {\r\n                (Get-Date) - $this.creationdate} \r\n                $data | Add-Member -MemberType ScriptProperty -Name Owner -Value {\r\n                $owner = $this | Invoke-CimMethod -MethodName GetOwner\r\n                #write the owner information\r\n                \"$($owner.domain)\\$($owner.user)\"\r\n                } \r\n                \r\n                if ($Full) {\r\n                    #write the full process object with additions to the pipeline\r\n                    $data\r\n                }\r\n                else {\r\n                    #get process summary\r\n                    $data | Select ProcessID,CreationDate,RunTime,Owner,PSComputername  \r\n                  }    \r\n\r\n            } #if $data\r\n\r\n         } #try\r\n\r\n         Catch {\r\n           Write-Warning \"Could not query $computer\"\r\n           Write-Warning $myErr.ErrorRecord.Exception.Message\r\n           Write-Debug \"Suspend script to debug `$myErr exception\"\r\n         } #catch\r\n\r\n     } #if test-connection works\r\n     else {\r\n       Write-Warning \"Failed to ping $computer\"\r\n     }\r\n\r\n} #foreach computer\r\n} #process\r\n\r\nEnd {\r\n Write-verbose \"Ending Get-PSRemoteSession\"\r\n} #end\r\n\r\n} #end function<\/pre>\n<p>This function takes a computername as a parameter. It does a quick ping to verify the computer is running. I probably should have made that optional, but I needed it at the time.  The function then queries the computer using Get-CimInstance for all instances of the wsmprovhost.exe process. I'm using CIM because datetime values are automatically formatted which makes it much easier to add a custom property indicating how long the process, and presumably the remote session, have been running. I also add a custom property to get the process Owner.  Due to a quirk (bug?) in the CIM cmdlets, I can even query a remote computer running PowerShell 2.0. When using a filter, the CIM cmdlets work with a v2 computer. I won't question it but will take advantage of it.<\/p>\n<p>By default, the function writes a summary object to the pipeline.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-1-300x255.png\" alt=\"get-psremotesession-1\" width=\"300\" height=\"255\" class=\"aligncenter size-medium wp-image-3817\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-1-300x255.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-1.png 647w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The one thing I have yet to figure out is a way to show what computer each session is connected from. Although even if I could make the correlation with an active network connection, I'm not sure that would help in the event of a disconnected session. Nor can I tell the state of the session from the process.<\/p>\n<p>I included an option to get the full process object so you could run commands like this:<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-2-300x203.png\" alt=\"get-psremotesession-2\" width=\"300\" height=\"203\" class=\"aligncenter size-medium wp-image-3818\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-2-300x203.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-2.png 753w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>But I suspect for many of you the summary will suffice. Here are some examples.<\/p>\n<pre class=\"lang:ps decode:true \" >Get-Content c:\\work\\chi.txt | get-psremotesession | out-gridview -title \"Remote Sessions\"<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-3-300x124.png\" alt=\"get-psremotesession-3\" width=\"300\" height=\"124\" class=\"aligncenter size-medium wp-image-3819\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-3-300x124.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-3.png 773w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-4-300x68.png\" alt=\"get-psremotesession-4\" width=\"300\" height=\"68\" class=\"aligncenter size-medium wp-image-3821\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-4-300x68.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-4.png 1005w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-5-300x215.png\" alt=\"get-psremotesession-5\" width=\"300\" height=\"215\" class=\"aligncenter size-medium wp-image-3822\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-5-300x215.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/get-psremotesession-5.png 999w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>If you kill the wsmprovhost process, that will break the PSSession so be careful. But at least now you have a way of identifying what sessions might be open. I hope you'll let me know what you think.  Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>During a recent PowerShell training class we naturally covered PowerShell remoting. During the discussion I explained that a remote PSSession is essentially transparent to any currently logged on user. Unless of course you reboot the computer! One way you can identify a remote session is by the presence of the wsmprovhost process. You should see&#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":"Get Remote #PowerShell Session Connections http:\/\/wp.me\/p1nF6U-Zx","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],"tags":[534,460,87],"class_list":["post-3815","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-powershell","tag-pssession","tag-remoting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Remote PowerShell Session Connections &#8226; The Lonely Administrator<\/title>\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\/3815\/get-remote-powershell-session-connections\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Remote PowerShell Session Connections &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"During a recent PowerShell training class we naturally covered PowerShell remoting. During the discussion I explained that a remote PSSession is essentially transparent to any currently logged on user. Unless of course you reboot the computer! One way you can identify a remote session is by the presence of the wsmprovhost process. You should see...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-22T13:42:17+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass-150x150.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get Remote PowerShell Session Connections\",\"datePublished\":\"2014-04-22T13:42:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/\"},\"wordCount\":396,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/magnifying-glass-150x150.png\",\"keywords\":[\"PowerShell\",\"PSSession\",\"remoting\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/\",\"name\":\"Get Remote PowerShell Session Connections &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/magnifying-glass-150x150.png\",\"datePublished\":\"2014-04-22T13:42:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/magnifying-glass.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/magnifying-glass.png\",\"width\":288,\"height\":288},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3815\\\/get-remote-powershell-session-connections\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Remote PowerShell Session Connections\"}]},{\"@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":"Get Remote PowerShell Session Connections &#8226; The Lonely Administrator","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\/3815\/get-remote-powershell-session-connections\/","og_locale":"en_US","og_type":"article","og_title":"Get Remote PowerShell Session Connections &#8226; The Lonely Administrator","og_description":"During a recent PowerShell training class we naturally covered PowerShell remoting. During the discussion I explained that a remote PSSession is essentially transparent to any currently logged on user. Unless of course you reboot the computer! One way you can identify a remote session is by the presence of the wsmprovhost process. You should see...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-04-22T13:42:17+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass-150x150.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get Remote PowerShell Session Connections","datePublished":"2014-04-22T13:42:17+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/"},"wordCount":396,"commentCount":6,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass-150x150.png","keywords":["PowerShell","PSSession","remoting"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/","name":"Get Remote PowerShell Session Connections &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass-150x150.png","datePublished":"2014-04-22T13:42:17+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/magnifying-glass.png","width":288,"height":288},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3815\/get-remote-powershell-session-connections\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Get Remote PowerShell Session Connections"}]},{"@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":7257,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7257\/cross-platform-powershell-profiles-with-windows-terminal\/","url_meta":{"origin":3815,"position":0},"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":7242,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7242\/powershell-remoting-profiles-with-windows-terminal\/","url_meta":{"origin":3815,"position":1},"title":"PowerShell Remoting Profiles with Windows Terminal","author":"Jeffery Hicks","date":"February 10, 2020","format":false,"excerpt":"I have jumped in the deep end and fully committed to Windows Terminal as my default PowerShell environment. I love having one interface with tabs for different terminal profiles. Windows Terminal makes it easy for me to have tabs open to PowerShell 7, Windows PowerShell, an Ubuntu instance or even\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\/02\/image_thumb-8.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-8.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-8.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-8.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":7458,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7458\/a-powershell-remote-function-framework\/","url_meta":{"origin":3815,"position":2},"title":"A PowerShell Remote Function Framework","author":"Jeffery Hicks","date":"May 8, 2020","format":false,"excerpt":"The other day I shared a PowerShell function to query the registry on remote computers to find installed versions of PowerShell. The function leveraged PowerShell remoting with the flexibility of using a computer name with an optional credential or existing PSSessions. The more I thought about it, the more I\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\/05\/stop-remoteprocess.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":4597,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4597\/the-powershell-night-shift\/","url_meta":{"origin":3815,"position":3},"title":"The PowerShell Night Shift","author":"Jeffery Hicks","date":"November 19, 2015","format":false,"excerpt":"A few days ago I got a question on Twitter on how to push a long running command to the background but would also survive a user logoff. This is a pretty standard practice in the Linux world. In PowerShell we've had similar operations using the Start-Job cmdlet. With Start-Job\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"disconnecting again","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/11\/111915_1600_ThePowerShe8.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/11\/111915_1600_ThePowerShe8.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/11\/111915_1600_ThePowerShe8.png?resize=525%2C300 1.5x"},"classes":[]},{"id":7447,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/","url_meta":{"origin":3815,"position":4},"title":"Get Installed PowerShell Versions","author":"Jeffery Hicks","date":"May 7, 2020","format":false,"excerpt":"As is the norm for a typical day, I was working on one thing when I was distracted by a shiny rabbit hole (to mix some metaphors). Half a day later I have a new PowerShell function that not only might you find useful, but I think it has 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\/2020\/05\/get-psinstalled-result2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.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":3815,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3815","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=3815"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3815\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}