In yesteryears Microsoft was primarily focused on .NET to PowerShell which was only available in Windows. But with the recent shift in Microsoft towards customer preferences .NET was ported to Linux (and variants including OSX) and by extension run PowerShell on Linux and OSX.
Most of us are already familiar enough with the PowerShell on Windows. Lets see how to run and make use of PowerShell from Mac OSX and Linux
Mac OSX
Though there is no minimum requirement for the OSX version, its recommended to have OSX 10.10 (Yosemite) and above.
First and foremost download the PowerShell package from the Official distribution page (https://github.com/PowerShell/PowerShell/releases), powershell-6.0.0-alpha.9.pkg in our case
To install PowerShell on you mac, double click the downloaded .pkg file which will launch the package installer
Follow the on screen instructions to complete the installation
Now open the Terminal App and issue the command powershell to invoke the PowerShell
Linux
Get the PowerShell package for Linux from the Official distribution page (https://github.com/PowerShell/PowerShell/releases), .deb or .rpm in this case. Issue to following command and install the dependency
sudo apt-get install libunwind8 libicu55
After successful install, issue the below command to get the PowerShell installed on your Linux host
sudo dpkg -i /path to powershell.deb
Some deep dive..
So we installed PowerShell on OSX or Linux, whats next?
- PowerShell is very powerful, full fledged scripting language that works directly from the command line.
- PowerShell helps to automate tasks with ease
- PowerShell bridges many technologies with the ability to interact with .NET, COM, WMI, XML, Active Directory, etc..
Structured Command (Cmdlets)
PowerShell supports commands called as Cmdlets (pronounced as Command-Lets), for example Get-Process -Name L* will give details about the running processing that starts with letter L
Some cool things, PowerShell natively supports all .NET methods right from your Mac OSX or Linux. You can count the length of a string by using same .NET method, also use it as calculator
Command Discovery
You can discover all the PowerShell commands using a particular Cmdlet Get-Command, below example Get-Command *process* will give information not only on Cmdlet but also any Functions, Methods that contains the word process
Piping a Get-Member Cmdlet will provide the list of Properties and Methods of the Object
2 thoughts on “PowerShell on Mac OSX, Linux”
Comments are closed.