Poshland Blog is not only for Windows Users? Powershell Core on MacOS.


I’m so excited to publish a new post for You. Since few months I was planning to install and try Powershell Core on MacOS. If you follow my profile on the instagram, you know that I did this a few days ago. Maybe you want to ask me “Why?”. I want to replace my notebook with MacBook Pro. One of the requirements is still using my Powershell scripts on MacOS. I will test it for a few weeks and make a final decision.

Last year, I saw many articles and posts in social media about Powershell Core. Authors of these articles did a great job. However, I think that this is not enough to show all things for this topic. I decided to explain for all MacOS or Linux platform users that they also can use Powershell to improving your productivity in work in office or home. How can you do this? It’s simple. Install Powershell on your workstation and enjoy.

Windows Powershell vs. Powershell Core

Wait a moment? Windows Powershell and Powershell Core are not the same? That’s true. You can find many great articles like this or this, telling about the difference but often it’s high-level articles for IT Admins or developers. What with people who use Powershell to automate office job or more but don’t have developers high skills. Let’s try to compare these Powershell platform types one more time in a simple way.

Definitions

Windows Powershell is available since decade on Microsoft Windows operating systems. It’s based on the .NET Framework.

Powershell Core is the version of Powershell to install on many operating system types. Also, You can install Powershell Core on the Microsoft Windows operating system, but it won’t be the same default Windows Powershell.

To understand the difference between Windows Powershell and Powershell Core you have to check difference between .NET Framework and .NET Core. It’s still needed technical stuff to understand this. Let’s try to do this more easily. I will show you a few examples of difference.

Examples

Powershell Core have less aliases

The first difference is that Powershell Core has fewer aliases than the version in the Windows operating system. Why? Many of default aliases in Windows Powershell have the same name like native Linux commands. For example “ls” or “rm” is native Linux command so it can’t be included in Powershell Core by default. Let’s check the count of default aliases.

Windows Powershell default aliasses
Powershell Core default aliases on MacOS

Creating GUI for scripts

You can’t create User Interface for your script in Powershell Core. It’s only available in Windows Powershell. Let’s see an example to confirm that.


Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()


$Form = New-Object system.Windows.Forms.Form

$Form.ClientSize = '400,400'

$Form.text = "Form"

$Form.TopMost = $false

$Label = New-Object system.Windows.Forms.Label
$Label.text = "GUI for Powershell "
$Label.AutoSize = $true
$Label.width = 25
$Label.height = 10
$Label.location = New-Object System.Drawing.Point(16,24)
$Label.Font = 'Microsoft Sans Serif,10'

$Button1 = New-Object system.Windows.Forms.Button
$Button1.text = "OK"
$Button1.width = 60
$Button1.height = 30
$Button1.location = New-Object System.Drawing.Point(12,106)
$Button1.Font = 'Microsoft Sans Serif,10'

$Form.controls.AddRange(@($Label,$Button1))
$form.ShowDialog()
Creating GUi on Windows Powershell
Creating GUI in Powershell Core

Default commands count

Let’s check default count of Powershell command after launch Powershell console. I loaded the same modules in both versions of the Powershell console. By default, the Windows Powershell version has available more commands.


3 default module commands count in Windows Powershell console

3 default module commands count in Powershell Core console

Command Examples

Now appear new question which commands are available and which aren’t. I will show you a few examples.

Conclusion

Now it’s time, to sum up. As you can see Powershell is cross-platform. I showed you a few examples of difference, and we can tell that Powershell Core has fewer commands than Windows Powershell. However, when you check the details, you can see that Powershell Core hasn’t include commands to configure the Windows operating system. You don’t need commands like Get-WmiObject because Linux or MacOS don’t have WMI. If you didn’t use Powershell because you are MacOS or Linux user, just start learn now.

Let’s sum up. If you want to use your script not only on the Windows operating system:

  • Don’t use aliases in your script
  • Don’t build GUI based on Windows Forms library
  • Test your code in Powershell Core console.

Have you tried ever Powershell on MacOS or Linux. Please leave your opinion in the comments.

Get Access to Poshland Resources for FREE!!!

Signup now and receive an email once I publish new content.

I agree to have my personal information transfered to MailChimp ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.


Damian Garbus

Hi, My name is Damian. I'm Powershell geek. Also, I love to improve my productivity and yourself development. I connected Powershell and my productivity tricks and built this blog. You can find here how to learn Powershell and use this to improve your productivity. Enjoy.

Leave a Reply

Your email address will not be published.