Author : MD TAREQ HASSAN | Updated : 2023/03/16

Installing PowerShell using chocolatey

# open cmd as administrator
choco install powershell-core -y


# open cmd as administrator
choco upgrade powershell-core -y

Installing PowerShell using Windows PowerShell

Open Windows PowerShell as administrator

# Installation wizard will show up
iex "& { $(irm } -UseMSI" 

# No installation wizard
iex "& { $(irm } -UseMSI -Quiet"

# To install preview
iex "& { $(irm } -Preview -UseMSI -Quiet"

# Note:
# Long version of above command-
# Invoke-Expression "& { $(Invoke-Restmethod } -UseMSI"

Upgrade: the above commands will install latest/preview version side by side with currently installed version of PowerShell.

Installing PowerShell using cmd

# open cmd as administrator
# check latest version:

curl --remote-name --location --url

msiexec.exe /package %userprofile%\Downloads\PowerShell-7.3.0-preview.6-win-x64.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1 USE_MU=1 ENABLE_MU=1

Version check


Uninstalling PowerShell

# open cmd as administrator
choco uninstall powershell-core -y
choco uninstall powershell-core -y -f

If installed using windows powershell or cmd, then uninstall from control panel.


PowerShellGet is the module manager for PowerShell.

# Check PowerShellGet module is installed or not
Get-Module -Name PowerShellGet -Listavailable

# If PowerShellGet module is not installed, then install PowerShellGet module
# Install/Update PowerShellGet module
# Check latest version of PowerShellGet:
# If installation fails, try using follwoing flags (
# -AllowClobber -SkipPublisherCheck
# Install-Module -Name PowerShellGet -RequiredVersion 2.2.5 -Force
Install-Module PowerShellGet -Repository PSGallery -Force
Install-Module PowerShellGet -Force # Dafault Repository: PSGallery

Uninstall AzureRM from Windows PowerShell


Open Windows PowerShell as admin

Get-Module -ListAvailable | Where {$_.Name -like 'AzureRM.*'}

uninstall-module Azure
uninstall-module AzureRM

$Modules = Get-Module -ListAvailable | Where {$_.Name -like 'AzureRM.*'}
Foreach ($Module in $Modules) {Uninstall-Module $Module}


Installing Az module using chocolatey

Open PowerShell Core as admin

# Install Az module
choco install az.powershell -y --params="'/core'"

choco install az.powershell -y -f --params="'/core'" # forcing


choco upgrade az.powershell -y --params="'/core'"


choco uninstall az.powershell -y --params="'/core'"

choco uninstall az.powershell -y -f --params="'/core'" # forcing

Installation check

Get-Module -Name "Az.*" -Listavailable # Az modules only

Get-Module -Name "Az*" -Listavailable # includes AzureRM modules

Installing Az module using PowerShellGet

# Check Az module is installed or not
# Get-InstalledModule -> only shows modules that are installed using PowerShellGet, does not show modules installed using other tools i.e. Chocolatey
# Get-Module -> shows all modules - either installed using PowerShellGet or other tools i.e. Chocholatey
Get-InstalledModule -Name Az

Get-Module -Name Az -Listavailable
Get-Module -Name "Az*" -Listavailable
Get-Module -Name "Az.*" -Listavailable

# Default repository is PSGallery, you can specify repository explicitly: -Repository PSGallery
Install-Module -Name Az
Install-Module -Name Az -Force
Install-Module -Name Az -Force -AllowClobber
Install-Module -Name Az -Force -AllowClobber -Scope AllUsers

# Check all versions of Az module that are installed in your PC using PowerShellGet
Get-InstalledModule -Name Az # Get-InstalledModule -Name Az -AllVersions -OutVariable AzVersions
Get-InstalledModule -Name "Az*"
Get-InstalledModule -Name "Az.*"

Az module in Windows PowerShell

# ===================================================================================================
# Installation Using Chocolatey
# ===================================================================================================
choco install az.powershell -y

# PowerShell script execution policy must be set to remote signed or less restrictive
# Get-ExecutionPolicy -List can be used to determine the current execution policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# Using the Install-Module cmdlet is the preferred installation method for the Az PowerShell module
# Install the Az module for the current user only is the recommended installation scope
#Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force -AllowClobber
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

# Now uninstall AzureRM

VSCode integration


VS Code PowerShell Extension

Open VS Code and install powershell extension if not installed

VS Code PowerShell extension

Check that PowerShell core (PowerShell 7) is being used by VS Code PowerShell Extension:

Set PowerShell core (PowerShell 7) as integrated shell in VS Code


Visual Studio integration

PowerShell Core (PowerShell 7) in Visual Studio Terminal

PowerShell Tools for Visual Studio (Paid tool)

Install PowerShell Tools for Visual Studio

Menu > View => PowerShell => PowerShell Interactive Window

PowerShell Interactive Window