Run Powershell Commands From The Azure Portal

Introduction

If you need to run PowerShell scripts for virtual machines without having to RDP into a virtual machine or if you do not have access to the virtual machines at the OS level, you can do so through the Azure portal's Run Command under the VM plane.

The run command uses the Virtual Machine agent to run the script inside the virtual machine.

Step 1

Currently, we have a Virtual Machine, and we have enabled the HTTP and HTTPS in the Network Security Group (NSG).

Run Powershell commands from the Azure Portal

Step 2

When I copy and paste the Public IP for my VM, the page is not displayed because we don't install Internet Information Services (IIS) on the VM.

Run Powershell commands from the Azure Portal

Step 3

Select the run command under the operations and then select RunPowerShellScript.

Run Powershell commands from the Azure Portal

Step 4

Enter the below commands and click Run.

Install-WindowsFeature -name Web-Server -IncludeManagementTools

Run Powershell commands from the Azure Portal

Step 5

The Internet Information Service (IIS) installation has been successfully completed.

Run Powershell commands from the Azure Portal

Step 6

When we refresh the browser the Internet Information Service (IIS) will load. Now if we want to host our own website in the virtual machine, login to the virtual machine and upload the website files.

Run Powershell commands from the Azure Portal

Summary

In this article, we learned how to Run PowerShell commands on the OS through the Azure Portal. Please use the comments box for further clarification.


Similar Articles