{"id":1715,"date":"2022-02-27T19:55:44","date_gmt":"2022-02-28T03:55:44","guid":{"rendered":"https:\/\/tungle.ca\/?p=1715"},"modified":"2023-01-31T20:57:00","modified_gmt":"2023-02-01T04:57:00","slug":"enable-winrm-on-workgroup-machine-or-windows-server","status":"publish","type":"post","link":"https:\/\/tungle.ca\/?p=1715","title":{"rendered":"Enable WinRM on a Workgroup machine or Windows server"},"content":{"rendered":"\n<p>Open PowerShell with administrator right to enable WinRM. Then type the following command, and press &#8220;Y&#8221; two times.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">winrm quickconfig<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-258.png\" alt=\"\" class=\"wp-image-1716\" width=\"651\" height=\"351\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-258.png 987w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-258-300x162.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-258-768x415.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-258-200x108.png 200w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/figure>\n\n\n\n<p>If your network connection type is Public, you will get an error below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-9.png\" alt=\"\" class=\"wp-image-1747\" width=\"641\" height=\"179\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-9.png 965w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-9-300x84.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-9-768x216.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-9-200x56.png 200w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" \/><\/figure>\n\n\n\n<p>Go to Windows Firewall, and select &#8220;Public&#8221; on the Profiles setting to allow to connect via Public network.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"666\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-10-1024x666.png\" alt=\"\" class=\"wp-image-1749\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-10-1024x666.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-10-300x195.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-10-768x499.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-10-200x130.png 200w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/03\/image-10.png 1181w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Test the WinRM configuration by running the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">winrm identify -r:http:\/\/localhost:5985 -auth:none<\/code><\/pre>\n\n\n\n<p>If the test is successful as in the screenshot below, your device is able to be managed via WMI.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"810\" height=\"183\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-259.png\" alt=\"\" class=\"wp-image-1717\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-259.png 810w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-259-300x68.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-259-768x174.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-259-200x45.png 200w\" sizes=\"auto, (max-width: 810px) 100vw, 810px\" \/><\/figure>\n\n\n\n<p>Check WinRM port is running. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-260-1024x595.png\" alt=\"\" class=\"wp-image-1718\" width=\"521\" height=\"303\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-260-1024x595.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-260-300x174.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-260-768x446.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-260-200x116.png 200w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-260.png 1119w\" sizes=\"auto, (max-width: 521px) 100vw, 521px\" \/><\/figure>\n\n\n\n<p>Remotely check WinRM port has listened on Windows machine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Test-NetConnection WIN102022-01 -port 5985<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-261.png\" alt=\"\" class=\"wp-image-1719\" width=\"491\" height=\"199\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-261.png 951w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-261-300x122.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-261-768x313.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-261-200x81.png 200w\" sizes=\"auto, (max-width: 491px) 100vw, 491px\" \/><\/figure>\n\n\n\n<p>Enter WMI or WinRM credential for workgroup machine or Windows server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">PS C:\\Windows\\system32&gt; $wmiuser, $wmisecret = (read-host 'Enter the WMIuser'), (Read-Host 'Enter the WMIsecret' -AsSecureString)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"60\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-263-1024x60.png\" alt=\"\" class=\"wp-image-1721\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-263-1024x60.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-263-300x18.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-263-768x45.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-263-200x12.png 200w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-263.png 1336w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>A newadmin user is member of local Administrators on Windows workgroup machine or Windows server.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"361\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-270.png\" alt=\"\" class=\"wp-image-1730\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-270.png 717w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-270-300x151.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-270-200x101.png 200w\" sizes=\"auto, (max-width: 717px) 100vw, 717px\" \/><\/figure>\n\n\n\n<p>Create wmi_cred_new variable for WMI or WinRM credential.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$wmi_cred_new = New-Object System.Management.Automation.PSCredential($wmiuser, $wmisecret) <\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-264-1024x20.png\" alt=\"\" class=\"wp-image-1722\" width=\"840\" height=\"16\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-264-1024x20.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-264-300x6.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-264-768x15.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-264-200x4.png 200w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-264.png 1309w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/figure>\n\n\n\n<p>Check hostname and ipconfig on a remote host via WinRM.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Invoke-Command -ComputerName WIN102022-01 -Credential $wmi_cred_new -ScriptBlock {hostname; ipconfig}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"120\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-269-1024x120.png\" alt=\"\" class=\"wp-image-1727\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-269-1024x120.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-269-300x35.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-269-768x90.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-269-200x23.png 200w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-269.png 1327w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Check current OS Windows Patch.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Invoke-Command -ComputerName WIN102022-01 -FilePath C:\\Shared\\Get-CurrentPatchInfo.ps1 -Credential $wmi_cred_new<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-266-1024x278.png\" alt=\"\" class=\"wp-image-1724\" width=\"634\" height=\"172\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-266-1024x278.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-266-300x82.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-266-768x209.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-266-200x54.png 200w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-266.png 1431w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/figure>\n\n\n\n<p>Get Lastreboot and uptime on Windows 10 workgroup machine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Invoke-Command -ComputerName WIN102022-01 -Credential $wmi_cred_new -ScriptBlock {$OS1 = Get-WmiObject Win32_operatingsystem -Computer WIN102022-01 ; $LastReboot =($OS1.ConvertToDateTime($OS1.LastBootUpTime)) ; $LastReboot ; $Uptime = (Get-Date) -$OS1.ConvertToDateTime($OS1.LastBootUpTime) ; $Uptime  = ([String]$Uptime.Days + \" Days \"  + $Uptime.Hours + \" Hours \" + $Uptime.Minutes + \" Minutes\") ; $uptime}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"155\" src=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-268-1024x155.png\" alt=\"\" class=\"wp-image-1726\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-268-1024x155.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-268-300x46.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-268-768x117.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-268-200x30.png 200w, https:\/\/tungle.ca\/wp-content\/uploads\/2022\/02\/image-268.png 1325w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Open PowerShell with administrator right to enable WinRM. Then type the following command, and press &#8220;Y&#8221; two times. If your network connection type is Public, you will get an error below. Go to Windows Firewall, and select &#8220;Public&#8221; on the Profiles setting to allow to connect via Public network. Test the WinRM configuration by running [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,7],"tags":[23,12],"class_list":["post-1715","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-powershell","tag-micosoft","tag-powershell"],"_links":{"self":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts\/1715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1715"}],"version-history":[{"count":7,"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts\/1715\/revisions"}],"predecessor-version":[{"id":4681,"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts\/1715\/revisions\/4681"}],"wp:attachment":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}