Installing PowerShell Core in Server Core

In the following Virtual machine scenario, I got one Server Core with Active Directory (Build 16299) and Windows 10 (Build 16299) joined to my new domain. Both Build 16299.
On my Windows client I create a shared folder named “SharedFiles”, where I copy over the latest MSI version of PowerShell Core “PowerShell-6.0.0-win-x64.msi”.

Then, on the Server Core I’m going to create a map drive to my Windows client shared folder to then run the MSI installation from Windows PowerShell Console.

Install Steps

Here are the steps on Server Core Command Prompt:

1. Open Windows PowerShell:

## - Start PowerShell:

2. Map network drive to Windows Client shared folder, then change drive:

## - Map network drive:
New-PSDrive -Name "m" -PSProvider "FileSystem" -Root "\\systemname\sharedfolder";

## - Change to drive to "m:" and verify the MSI file is there:

3. At the “m:” drive, execute the installation with the following command:

## - Start installing PowerShell Core:
msiexec /i .\PowerShell-6.0.0-win-x64.msi /q

4. As this is a silent installation, so give it a few minutes, then exit to the command prompt

## - type "exit" to get back to the command prompt

## - Change directory to PowerShell Core, and execute pwsh.exe:
cd "C:\Program Files\PowerShell\6.0.0"

Setting ExecutionPolicy and Update Help

It has become a routine that after first time openning Powershell, that we need to: 1) set the ExecutionPolicy, and update the help documentation:

So, setting the execution policy, pick the one you need. The most common ones are: “RemoteSigned”, “ByPass”, “AllSigned”, “Unrestricted”.

## - Example setting ExecutionPolicy as "RemoteSigned"
Set-ExecutionPolicy -ExecutionPolicy "RemoteSigned";

Then, its very important to update the help documentation. I had the tendency to always include to parameter “-Force“:

## - Updating Help documentation:
Update-Help -Force

And, you’re ready to work with PowerShell Core on Server Core.

Oh! How to uninstall PowerShell Core

Let go a little further. Here are the steps to successfully uninstall PowerShell Core on Server Core.
Open Windows PowerShell, make a list of all installed products using Get-WMIObject command:

## - Listing installed products
get-wmiobject Win32_Product `
Select IdentifyingNumber, Name, LocalPackage `
| Format-Table -AutoSize;

This will confirmed PowerShell Core is installed. Pay close attention to the “IdentifyingNumber” property which is really the product GUID.

Now, we can proceed to uninstall PowerShell Core. There are two way to execute a product MSI uninstall:

1. Providing the installation path with filename:

## - Executing Uninstall MSI silently and write to log file: (Using filename)
msiexec.exe /x "c:\filename.msi" /qn /lv "C:\msilogfile.log"

2. Using the IdentifyingNumber (Product GUID) listed when executing the Get-WMIObject:

## - Executing Uninstall MSI silently and write to log file: (Using Product GUID)
msiexec.exe /x '{11111111-1111-1111-1111-11111111111X}'dir /qn /lv "C:\msilogfile.log"

Image below doing MSI uninstall using GUID:

Both examples, include the use to write to a log file “C:\msilogfile.log“, along with the necessary switches to uninstall and execute silently. (Above switches are lowercase)

Additional Information

Check the following links on:

1. Installing MSI files with PowerShell:

2. Report or check any issues with PowerShell Core:

3. PowerShell Core Reach GA (Generally Available) status:

Be Bold!! Learn PowerShell Core!!

This entry was posted in PowerShell, Resources, Windows 2012, Windows Server 2016. Bookmark the permalink.