[Build and Deploy Staging Site] Publish from microsoft/azuretipsandtricks-private:main/src/blog
This commit is contained in:
Родитель
ffa92685be
Коммит
92b2433657
|
@ -1,83 +0,0 @@
|
|||
---
|
||||
type: post
|
||||
title: "Tip 198 - PowerShell Core on Linux is now integrated with Azure Cloud Shell"
|
||||
excerpt: "Learn about PowerShell Core in Azure Cloud Shell"
|
||||
tags: [Languages & Frameworks]
|
||||
share: true
|
||||
date: 2019-05-19 02:00:00
|
||||
---
|
||||
|
||||
::: tip
|
||||
:bulb: Learn more : [PowerShell Core on Linux](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-6?WT.mc_id=docs-azuredevtips-azureappsdev).
|
||||
|
||||
:tv: Watch the video : [How to use PowerShell Core on Linux](https://www.youtube.com/watch?v=iLK8SkkHHjo&list=PLLasX02E8BPCNCK8Thcxu-Y-XcBUbhFWC&index=56&?WT.mc_id=youtube-azuredevtips-azureappsdev).
|
||||
:::
|
||||
|
||||
### PowerShell Core on Linux is now integrated with Azure Cloud Shell
|
||||
|
||||
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?
|
||||
|
||||
<img :src="$withBase('/files/AzureCloudShell.png')">
|
||||
|
||||
(Azure Cloud Shell)
|
||||
|
||||
Here are some quick tips of things that you can now do in Azure Cloud Shell:
|
||||
|
||||
##### 1. Navigate through your Azure resources
|
||||
|
||||
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.
|
||||
|
||||
<img :src="$withBase('/files/NavigateThoughAzureResources.png')">
|
||||
|
||||
(Navigate through Azure resources using Azure Cloud Shell)
|
||||
|
||||
##### 2. Commands are scoped to the location you are in
|
||||
|
||||
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**.
|
||||
|
||||
<img :src="$withBase('/files/CommandsAreScopedToLocation.png')">
|
||||
|
||||
(You don't have to add the -ResourceGroupName parameter to Get-AzVM)
|
||||
|
||||
##### 3. Easily Remote PowerShell into a VM
|
||||
|
||||
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.
|
||||
|
||||
<img :src="$withBase('/files/EnablePSRemoting.png')">
|
||||
|
||||
(Enable PowerShell Remoting)
|
||||
|
||||
Now, you can use **Enter-AzVM** to log into the VM using PowerShell Remoting.
|
||||
|
||||
<img :src="$withBase('/files/EnterVM.png')">
|
||||
|
||||
(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.
|
||||
|
||||
<img :src="$withBase('/files/PSVersionInRemoteVM.png')">
|
||||
|
||||
(Checking the PowerShell version in the VM)
|
||||
|
||||
##### 4. Switching to Bash
|
||||
|
||||
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**.
|
||||
|
||||
<img :src="$withBase('/files/SwitchToBash.png')">
|
||||
|
||||
(Switch to Bash using the **bash** command)
|
||||
|
||||
##### 4. Check the PowerShell version
|
||||
|
||||
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.
|
||||
|
||||
<img :src="$withBase('/files/PowerShellVersion.png')">
|
||||
|
||||
(See the PowerShell version in Azure Cloud Shell)
|
||||
|
||||
##### Conclusion
|
||||
|
||||
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/.
|
||||
|
Загрузка…
Ссылка в новой задаче