💡 Learn more : PowerShell Core on Linux.
📺 Watch the video : How to use PowerShell Core on Linux.
Azure Cloud Shell is one of the easiest way to command-line your way through the cloud. It has the Azure CLI integrated and it just runs. Now, when you open a new Azure Cloud Shell instance (https://shell.azure.com')">, Cloud Shell opens up an instance for you in a container that runs on Linux. And on there, it runs PowerShell Core. Isn't that awesome?
(Azure Cloud Shell)
Here are some quick tips of things that you can now do in Azure Cloud Shell:
Here is something that I find very useful. You can use Azure Cloud Shell to navigate through your Azure resources. You can, for instance, cd into your subscription, and see which resources you have. You can just do dir allresources to see all of the resources that you have. Or narrow it down by doing something like dir webapps to see all of your Web Apps.
(Navigate through Azure resources using Azure Cloud Shell)
When you've navigated to, let's say, a resource group using cd ResourceGroups\ResourceGroupName, all of the commands that you perform are scoped to that resource group. This means that when you type in Get-AzVM, which lists all of your Virtual Machines, you don't have to add the parameter -ResourceGroupName.
(You don't have to add the -ResourceGroupName parameter to Get-AzVM)
You can also easily using PowerShell Remoting to control another machine. First, you need to enable PowerShell Remoting. And as we are already in the context of the resource group, we don't have to put in the -ResourceGroupName parameter.
(Enable PowerShell Remoting)
Now, you can use Enter-AzVM to log into the VM using PowerShell Remoting.
(Enter-AzVM to log into a VM using PowerShell Remoting)
And once you are in the VM, you see that the prompt changes to the C:\ drive. We are now literally in the VM. From here, we can type $PSVersionTable to see which version of PowerShell we are running. And as you can see in the image below, the VM runs PowerShell Desktop, so not PowerShell Core. And it runs version 5, not 6.
(Checking the PowerShell version in the VM)
You could always switch from a PowerShell to a Bash prompt using the menu in the top. Now, you can also switch from the PowerShell prompt to Bash, by typing bash. And you can switch back by typing exit.
(Switch to Bash using the bash command)
When you type in $PSVersionTable, you'll see the version of PowerShell that is running, which determines the capabilities that you can use. the command is not new. But now, out-of-the-box, Cloud Shell is running the new PowerShell Core and runs on Linux.
(See the PowerShell version in Azure Cloud Shell)
Azure Cloud Shell is an amazing service that allows you to use powerful commandline tools from the browser. Now, with PowerShell Core, the Cloud Shell has become even more useful. Go and check it out at https://shell.azure.com/.