#Setup a New Microsoft Windows Server 2019 Core Installation to Accept Incoming PowerShell Remoting connections in a Workgroup
#You will not need to do this if you perform your PowerShell tasks directly from your server. You need this if you have virtual machines or headless devices… or just plain lazy. Also not everyone has a domain controller and sometimes even a Hyper-V host computer will remain in a workgroup since it might host the domain controller and it is off topic… I work in PowerShell ISE for the most part and connect to where ever I need to.
#This is the first steps after a fresh clean install of Microsoft Windows Server 2019 Core to allow PowerShell Remoting and WSMan.
#Press Ctrl-Alt-Delete to begin configuring Microsoft Windows Server 2019 Core
#Press Enter to select OK to change password
#Set password for .\administrator
#This initial password is for the local administrator account .\administrator is also a way to access this account. It is not part of active directory and therefore doesn’t fall under the Active Directory password policy. Do not make it something easy to guess. The standard policy require 8 characters minimum with upper and lower case letters, numbers and symbols. I suggest you follow that as this password will be passed to your initial domain administrator account, where it will fail to work, so it is just best to avoid issues.
#This is cmd.exe start screen for Microsoft Windows Server 2019 Core. Type sconfig to bring up the cheater menu.
#Type powershell and press enter to start a PowerShell session directly in Microsoft Windows Server 2019 Core cmd.exe prompt.
#Type Enable-PSRemoting -Force to enable PowerShell Remoting. You can use -SkipNetworkProfileCheck to allow management requests on a network Microsoft Windows has categorized as Public such as Hotspots and new unrecognized networks.
Enable-PSRemoting -Force
#This will show you what computers you “trust” to connect remotely via PowerShell Remote, no remote hosts are allowed by default.
Get-Item WSMan:\localhost\Client\TrustedHosts
#This adds the computers you “trust” to make PowerShell Remote connections to. It doesn’t need a value if you don’t connect to other computers from the server and just have a management PC you use to connect remotely to the server. This is not to allow client PCs to use Enter-PSSession to connect to the server and most likely you need to run this command on a Windows 10 computer instead.
Get-Item WSMan:\localhost\Client\TrustedHosts|Set-Item -Value '10.4.0.2,BEAKER'
#You can use either the server IP address or computer name if you need to perform this step. I choose to use both so I avoid any issues when connecting. You need to type y and press Enter to confirm. A value of ‘*’ allows the server to connect to any remote host.
#Now you can use Enter-PSSession to connect to your Microsoft Windows Sever 2019 Core install to configure it using PowerShell or RSAT tools.
#At this point you should not have Active Directory installed so you would use this command to connect. I use PowerShell ISE to open my command list and run them remotely.
Enter-PSSession -Cn 10.4.0.2 -Credential administrato
#If you are running you Microsoft Windows 2019 Core on Hyper-V then you can connect this way above and to perform these steps you could connect this way first rather than using the server console. Be aware that connecting -VMName Vs. -ComputerName can cause some commands to behave differently or not at all.
Enter-PSSession -VMName Server2019 -Credential administrator