Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Connect to Microsoft Azure using Windows PowerShell

August 10, 2022
in Blog, Microsoft Azure, Powershell
0
ADVERTISEMENT

Table of Contents

Bypassing the Azure Portal and going straight to PowerShell will provide you with more options for managing Microsoft’s cloud.

Installing the Azure PowerShell Module

To get started, you’ll need to download and install the Azure PowerShell module. This is a module provided by Microsoft.

1. Azure PowerShell requires your connecting machine to be running PowerShell version 5.0. To check, run command $PSVersionTable and confirm the Major build is 5.

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682

2. Right click on Windows start icon then open Windows PowerShell Admin.

Pw3

3. Run the following commands at once to install Azure PowerShell modules. This installation will take a few minutes. Once installed, you can connect your Azure subscription.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name Az -AllowClobber -Scope CurrentUser
ADVERTISEMENT

Connecting Your Azure Subscription

After you’ve gotten the Azure module installed, run this command Connect-AzAccount. This will bring up a small page asking you to input your account that has an active Azure subscription attached to it.

If all goes well, you should see an output showing your Account, Subscription and tenant information.

Connect-AzAccount

Account                 SubscriptionName         TenantId                             Environment
-------                 ----------------         --------                             -----------
[email protected] Azure Pass - Sponsorship dc65dd64-6886-40f2-b247-5b10d8fb5a66 AzureCloud

Once this happens, you’re ready to begin looking around to see what you can do. If you happen to have more than one subscription you can switch between them.

Starting/Stopping an Azure Iaas Virtual Machine

One of the most common Azure resources is its Infrastructure-as-a-service (IaaS) platform. If you’re already using Azure you most likely already have a few Azure VMs running in the cloud.

Let’s try to start and stop an existing VM from PowerShell.  First, let’s just run Get-AzVM and check out all of the VMs we currently have running under your subscription.

Get-AzVM -Status

ResourceGroupName      Name      Location       VmSize  OsType  Provisioning PowerState 
-----------------      ----      --------       ------  ------  ------------ ---------- 
AUSTRALIAEAST-RG     vm-001 australiaeast Standard_B2s Windows     Succeeded VM running
AUSTRALIAEAST-RG  win11-001 australiaeast Standard_B2s Windows     Succeeded VM running

You’ll see that I have two VMs and that the PowerState property is VM Running (it’s running). We”ll try to stop a VM using Stop-AzVM command.

Note Note: The StayProvisioned parameter on Stop-AzureVM, this is necessary if you want to keep the current IP address of your VM. Without this, you'd lose the IP address and risk obtaining a new one. Depending on your situation this may or may not be necessary.
Stop-AzVM -Name "vm-001" -ResourceGroupName "AUSTRALIAEAST-RG" -StayProvisioned

Virtual machine stopping operation
This cmdlet will stop the specified virtual machine. Do you want to continue?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

OperationId : ee000b52-b6e8-4c0a-a738-c64bc60a7530
Status      : Succeeded
StartTime   : 8/10/2022 9:00:36 PM
EndTime     : 8/10/2022 9:01:12 PM
Error       :
Get-AzVM -Status

ResourceGroupName      Name      Location       VmSize  OsType  Provisioning PowerState 
-----------------      ----      --------       ------  ------  ------------ ---------- 
AUSTRALIAEAST-RG     vm-001 australiaeast Standard_B2s Windows     Succeeded VM stopped
AUSTRALIAEAST-RG  win11-001 australiaeast Standard_B2s Windows     Succeeded VM running

We now have a stopped VM. Let’s bring it back up again. This is the super-easy part. All we need to do is pipe our VM to Start-AzVM and we’re done!

Start-AzVM -Name "vm-001" -ResourceGroupName "AUSTRALIAEAST-RG"

OperationId : eaf6c3d6-2857-4c45-9b34-3a64ed525846
Status      : Succeeded
StartTime   : 8/10/2022 9:09:05 PM
EndTime     : 8/10/2022 9:09:17 PM
Error       :
ADVERTISEMENT
5/5 - (2 votes)
Previous Post

How to Get the Azure VM Available Sizes Using PowerShell

Next Post

How to Enable and Connect to Microsoft Azure Cloud Shell

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory