Windows PowerShell the new Shell (first released in 2006) for Windows that provides the ability to implement Task Automation, and Configuration Management via a Command-Line Shell and PowerShell scripting language built on the .NET Framework. PowerShell is an extremely strong tool and has become a staple in managing various Windows systems from the OS to SharePoint to the cloud and Microsoft Azure. Today, Microsoft has officially released PowerShell cross-platform support via an Open Source project that supports Linux, macOS and Windows!
Now that PowerShell is open source and cross-platform, it’s important to know which platforms are supported. Here’s a list of the platforms with links to go download the installers along with links to installation instructions:
- Windows 10 / Server 2016 – Download – How to Install
- Windows 8.1 / Server 2012 R2 – Download – How to Install
- Ubuntu 16.04 – Download – How to Install
- Ubuntu 14.04 – Download – How to install
- CentOS 7 – Download – How to Install
- OX X 10.11 / macOS – Download – How to Install
Introduction of PowerShell on Linux and Open Source with Jeffrey Snover
Here’s a nice intro video from Jeffrey Snover (Technical Fellow at Microsoft) giving you all the details on what you need to know about PowerShell going Open Source!
Building from Source Code
As with any open source project, you can optionally either download the pre-built packages to install, or choose to build the project from the source code. PowerShell is not different, and here’s links to instructions on how to build PowerShell from source on the different supported platforms:
The source code for the PowerShell project is hosted on Github and can be downloaded locally by using Git from the command-line.
git clone --recursive https://github.com/PowerShell/PowerShell.git
Additionally, the PowerShell open source project is licensed under the MIT license.
PowerShell and Azure
Previously, the Azure CLI (or x-plat CLI) was the only option for managing Azure subscriptions and resources from the command-line on Linux and macOS. Now with the open source and cross-platform release of PowerShell, you’ll be able to manage all your Azure resources from Windows, Linux and macOS using your tool of choice, either the Azure CLI or Azure PowerShell cmdlets.
Fore reference, here’s some simple PowerShell script that shows a little of what it’s like to manage Azure resources from PowerShell:
# To make sure the Azure PowerShell module is available after you install Get-Module –ListAvailable # To login to Azure Resource Manager Login-AzureRmAccount # You can also use a specific Tenant if you would like a faster login experience Login-AzureRmAccount -TenantId xxxx # To view all subscriptions for your account Get-AzureRmSubscription # To select a default subscription for your current session Get-AzureRmSubscription –SubscriptionName "your sub" | Select-AzureRmSubscription # View your current Azure PowerShell session context # This session state is only applicable to the current session and will not affect other sessions Get-AzureRmContext # To select the default storage context for your current session Set-AzureRmCurrentStorageAccount –ResourceGroupName "your resource group" –StorageAccountName "your storage account name" # View your current Azure PowerShell session context # Note: the CurrentStorageAccount is now set in your session context Get-AzureRmContext # To list all of the blobs in all of your containers in all of your accounts Get-AzureRmStorageAccount | Get-AzureStorageContainer | Get-AzureStorageBlob
OSS PowerShell FAQ
Here are some answers to frequently asked questions regarding PowerShell:
How do the scoping rules in PowerShell work?
- Variables are created in your current scope unless explicitly indicated.
- Variables are visible in a child scope unless explicitly indicated.
- Variables created in a child scope are not visible to a parent unless explicitly indicated.
- Variables may be placed explicitly in a scope.
Where can I learn PowerShell’s syntax?
SS64.com website is a good resource.
What are the PowerShell best practices and styles?
The unofficial PowerShell Practice and Style Guide provides a good resource to reference for this.
Here’s a link to a more inclusive FAQ document in the PowerShell OSS project site.