{"id":750,"date":"2020-06-18T14:26:27","date_gmt":"2020-06-18T19:26:27","guid":{"rendered":"https:\/\/itblog.ldlnet.net\/?p=750"},"modified":"2020-06-18T14:33:56","modified_gmt":"2020-06-18T19:33:56","slug":"windows-server-core-how-to-have-powershell-automatically-start-when-logging-onto-the-session","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2020\/06\/18\/windows-server-core-how-to-have-powershell-automatically-start-when-logging-onto-the-session\/","title":{"rendered":"Windows Server Core &#8211; How to have PowerShell automatically start when logging onto the session."},"content":{"rendered":"\n<p>In my environment, I have a Windows Server (2019) Core edition server installed with Exchange 2019. Most of the time, I have to get on the server to run PowerShell commands for maintenance purposes, etc&#8230;<\/p>\n\n\n\n<p>Well, by default, Windows Server Core opens the command prompt when you logon and then I have to manually open PowerShell from there to run cmdlets, etc&#8230;<\/p>\n\n\n\n<p>However, if you would like to change the default cmd to PowerShell, you can change it by changing the Registry value.<\/p>\n\n\n\n<p>The Registry that I\u2019m talking is located under the following location:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\">HKLM:\\Software\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon <\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.msnoob.com\/wp-content\/uploads\/2019\/02\/change-shell-value-regedit.png?w=696&amp;ssl=1\" alt=\"\" class=\"wp-image-1574\"\/><figcaption>Change the Shell Value in the Registry<\/figcaption><\/figure>\n\n\n\n<p>The easiest way I see to change the value is to use the <strong><em>Set-ItemProperty<\/em><\/strong> cmdlet within PowerShell.<\/p>\n\n\n\n<p>Open Windows PowerShell within Server Core command prompt. You can type \u201cPowerShell\u201d on your command prompt.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i1.wp.com\/www.msnoob.com\/wp-content\/uploads\/2019\/02\/run-powershell-cmd.png?w=696&amp;ssl=1\" alt=\"\" class=\"wp-image-1575\"\/><\/figure>\n\n\n\n<p>Then, enter the following command on PowerShell console and hit enter:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Change Registry Key Value From PowerShell\">Set-ItemProperty -Path 'HKLM:\\Software\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon' -Name Shell -Value 'PowerShell.exe'<\/pre>\n\n\n\n<p>Once completed, you will need to reboot the computer from PowerShell:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Reboot Computer From PowerShell\">Restart-Computer -force<\/pre>\n\n\n\n<p>When the computer has rebooted and you have logged on, PowerShell should load by default instead of Command Prompt.<\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">EVEN MORE INFORMATION<\/h3>\n\n\n\n<p>Now, since I have an Exchange Server installed on this server, there is a Command in the $bin directory called <strong><em>LaunchEMS.cmd<\/em><\/strong> that will load the Exchange Management Shell for you. So instead of loading just PowerShell, I tell WinLogon to load Exchange Management Shell so that I do not have to do any additional typing or searching for EMS on the box. Remember, Server Core has no GUI!<\/p>\n\n\n\n<p>I run the same commands as above, but just change the value to <strong><em>LaunchEMS.cmd<\/em><\/strong><\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Change Registry Key Value From PowerShell\">Set-ItemProperty -Path 'HKLM:\\Software\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon' -Name Shell -Value 'LaunchEMS.cmd'<\/pre>\n\n\n\n<p>Then Restart the Computer:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Reboot Computer From PowerShell\">Restart-Computer -force<\/pre>\n\n\n\n<p>Once Rebooted, you can logon and EMS will be the only window prompt that loads in the shell!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"1024\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2020\/06\/image-4-975x1024.png\" alt=\"\" class=\"wp-image-751\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2020\/06\/image-4-975x1024.png 975w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2020\/06\/image-4-286x300.png 286w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2020\/06\/image-4-768x807.png 768w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2020\/06\/image-4-1462x1536.png 1462w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2020\/06\/image-4.png 1725w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><figcaption>Exchange Management Shell loads when you logon<\/figcaption><\/figure>\n\n\n\n<p class=\"has-text-color has-small-font-size has-medium-pink-color\">NOTE: <em>You can always run <strong>cmd <\/strong>from the prompt to open Command Prompt and also run <strong>PowerShell.exe <\/strong>to open regular PowerShell<\/em> from the EMS Session Window. <\/p>\n\n\n\n<h2 class=\"has-text-align-center wp-block-heading\">REMAIN POSITIVE!<br>THANKS FOR READING!<\/h2>\n\n\n\n<p class=\"has-small-font-size\"><strong>REFERENCES:<\/strong><br><em><a href=\"https:\/\/www.msnoob.com\/windows-server-core-how-to-start-powershell-by-default.html\" target=\"_blank\" rel=\"noreferrer noopener\">Windows Server Core: How to start PowerShell by Default<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my environment, I have a Windows Server (2019) Core edition server installed with Exchange 2019. Most of the time, I have<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2020\/06\/18\/windows-server-core-how-to-have-powershell-automatically-start-when-logging-onto-the-session\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":147,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2,3,16],"tags":[164,245,244,246,8,163,242,20,247,226,243],"class_list":["post-750","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-general","category-powershell","category-windows","tag-hklm","tag-launchems","tag-launchems-cmd","tag-logon","tag-powershell","tag-registry","tag-server-core","tag-windows","tag-windows-logon","tag-windows-server-core","tag-winlogon","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=750"}],"version-history":[{"count":3,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/750\/revisions"}],"predecessor-version":[{"id":755,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/750\/revisions\/755"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/147"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}