Now PowerShell Core v6.0 has been released I thought it would be a good idea to write an article on how to install it on Windows 10. I will also show you how to run Windows PowerShell modules using PowerShell Core v6.0
So what is PowerShell Core?
With the release of PowerShell Core, we now have two versions of PowerShell, Windows PowerShell and PowerShell Core. Windows PowerShell is built on top of .NET Framework and is know as FullCLR. Windows PowerShell, as the name implies can only be installed on Windows Client and Windows Server. PowerShell Core is built on top of .NET Core and is known as CoreCLR. PowerShell core can be installed on Windows, MacOS and various distributions of Linux.
One good thing about PowerShell core is the ability to run it alongside Windows PowerShell without affecting Windows PowerShell at all. Unfortunately, PowerShell Core only includes a few built-in modules.
So now we know what PowerShell Core is, let’s move on to how to install it.
Installing PowerShell Core
The first thing we need to do is download PowerShell Core from the following repository on GitHub. Here is a link to the Windows x64 version.
Once downloaded run the MSI. On the first screen click Next
Tick the box to accept the terms and conditions and click Next
Click Next
Click Install If prompted, enter you admin details.
Now you can tick the checkbox to launch PowerShell Core and then click Finish
You have now Installed PowerShell Core.
Launch PowerShell Core
To open PowerShell Core, you can find it in your start menu under PowerShell-6.0.0
Another way to open it is via a command window or a PowerShell window by typing pwsh
Now that we have PowerShell Core installed and we can start it, let’s look at adding in PowerShell Modules.
Run a Windows PowerShell Module in PowerShell Core
Microsoft has made an effort to make PowerShell Core as compatible as possible with Windows PowerShell. Unfortunately not all Windows PowerShell commands will work in PowerShell Core natively just yet. This is due to dependencies on the underlying .NET layers. As time goes on Microsoft will start to port more of their PowerShell Modules over to PowerShell Core.
For now, we can use the WindowsPSModulePath module from the PowerShell Gallery. This module allows us to use Windows PowerShell modules by appending the Windows PowerShell PSModulePath to the PowerShell Core PSModulePath.
Inside an elevated PowerShell Core window Type the following.
Install-Module WindowsPSModulePath -Force |
Now we use the following command to add the Windows PowerShell PSModulePath to PowerShell Core.
Add-WindowsPSModulePath |
Now we can use Any Windows PowerShell command we like. In the Image below I have used Get-VM
This is all well and good for a one time need, but say I want the Windows PowerShell commands to always be available in PowerShell Core. Well, I could type the above cmdlet every time I wanted to use a Windows PowerShell Module. Or I could just create a PowerShell Core Profile and add it to it.
In your elevated PowerShell Core Window type the following
if (!(Test-Path -Path $profile)) | |
{New-Item -ItemType File -Path $profile -Force} |
Next, we need to edit the Profile file. In the same PowerShell Core window type
Notepad $profile |
Add the following cmdlet in the notepad window and save it.
Add-WindowsPSModulePath |
Now we have the Profile setup and the module being added when PowerShell Core opens, we should be able to run any Windows PowerShell Commands in PowerShell Core.
Thanks for reading this blog post. I hope you found it useful. If you have any questions please leave a comment below or drop me a message on twitter or email.
1 Comment
Install PowerShell Core on Windows Subsystem for Linux - Ubuntu 16.04 - Pixel Robots. · February 11, 2018 at 8:48 pm
[…] In this article, I will go through the steps on how to install PowerShell Core on the Windows Subsystem for Linux. This can be useful for your scripting needs as it will give you a consistent language over both systems. You can also follow this guide to install PowerShell Core on a full Ubuntu Install. If you would like to see how to Install PowerShell Core on Windows you can read the how-to guide at this link. […]