Author : HASSAN MD TAREQ | Updated : 2021/12/01


“PowerShell” vs “Windows PowerShell”

Check PowerShell is intalled or not

Install Latest Version of PowerShell (not “Windows PowerShell”):

# Install latest version of PowerShell
# In the installation wizard, select "Do not close ..." -> you need to restart your PC
Invoke-Expression "& { $(Invoke-Restmethod } -UseMSI"

# Short version of above command
# iex "& { $(irm } -UseMSI"

Latest release:

Restart PC and check PowerShell is installed correctly

# Check current version

PowerShellGet Module

# 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

PowerShell in VS Code

PowerShell in Visual Studio

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

PowerShell Azure Module

Azure Az module in PowerShell

# Check Az module is installed or not
# If not installed, nothing will be retured after executing the command
Get-InstalledModule -Name Az # Get-Module -Name Az -Listavailable

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

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

# Now uninstall AzureRM

Azure Az module in “Windows PowerShell”

# 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

Using Latest PowerShell in PowerShell ISE

# Code snippet taken from:

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to PowerShell 7", { 
        function New-OutOfProcRunspace {

            $ci = New-Object -TypeName System.Management.Automation.Runspaces.NamedPipeConnectionInfo -ArgumentList @($ProcessId)
            $tt = [System.Management.Automation.Runspaces.TypeTable]::LoadDefaultTypeFiles()

            $Runspace = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace($ci, $Host, $tt)


        $PowerShell = Start-Process PWSH -ArgumentList @("-NoExit") -PassThru -WindowStyle Hidden
        $Runspace = New-OutOfProcRunspace -ProcessId $PowerShell.Id
}, "ALT+F5") | Out-Null

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to Windows PowerShell", { 

    $Child = Get-CimInstance -ClassName win32_process | where {$_.ParentProcessId -eq $Pid}
    $Child | ForEach-Object { Stop-Process -Id $_.ProcessId }

}, "ALT+F6") | Out-Null

Azure CLI

PowerShell command to Install Azure CLI

Invoke-WebRequest -Uri -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi

Upgrade Azure CLI

az upgrade

Check version

az --version

Azure CloudShell

Accessing Cloudshell

Initial Setup

How to Use Manifest File in Command (i.e. to deploy K8s workload)

Re-mount fileshare

Connecting and running cloudsehll in VS Code

Running Azure CloudShell Locally

PowerShell launcher script


$startShellType = "/usr/bin/pwsh" # PowerShell, for bash -> "/bin/bash"
$cloudshellImageName = ""

$sourceScriptFolder = "`"C:\az-cloudshell\scripts`""  # the folder where your local scrips are located, double quote is required ('`' to escape double quote)
$targetScriptFolder = "/usr/cloudshell"       # mounted folder in container 

$container = $(docker ps -q --filter ancestor=$cloudshellImageName)
$containerIsRunning = ($container -ne $null)

if ($containerIsRunning) { 

    Write-Host "Container is running. Connecting to container..."

    docker exec -it $container $startShellType

} else { 

    Write-Host "Container is not running. Updating container image..."

    docker pull "$($cloudshellImageName):latest"

    Write-Host "Mapping '$($sourceScriptFolder)' to '$($targetScriptFolder)'. Connecting to cloudshell (interactive)... `r`n`r`n"
    $volumeMount = "$($sourceScriptFolder):$($targetScriptFolder)"

    docker run -it -v $volumeMount $startShellType

Create shortcut with following

"C:\Program Files\PowerShell\7\pwsh.exe" -ExecutionPolicy Bypass -File "C:\az-cloudshell\cloudshell-launcer.ps1"

Now right click on shortcut and run (as “Admin” if required)

To connect azure account, use Device Authentication: DeviceAuthentication - Connect Azure Account in CloudShell when MFA is Enabled

Docker Desktop

Windows Subsystem for Linus 2 (WSL2)

Window 10

Windows VM

wsl commnads

wsl -l -v
wsl --list --online
wsl --install -d ubuntu
wsl --update
wsl --status

wsl --set-version <distro name> 2
wsl --set-version Ubuntu 2



Install chocolatey using PowerShell

# PowerShell console
Set-ExecutionPolicy Bypass -Scope Process -Force; `
  iex ((New-Object System.Net.WebClient).DownloadString(''))
#Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(''))

# PowerShell ISE
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(''))

Upgrade Chocholatey

choco upgrade chocolatey

Check Chocholatey version

choco upgrade pkgname --noop


Install pulumi using chocolatey

choco install pulumi -y

Check version

pulumi version


Install cmder using chocolatey

choco install cmder -y
# choco upgrade cmder

Open Cmder


Install kubectl using chocolatey

choco install kubernetes-cli -y
# choco upgrade kubernetes-cli

Check version

kubectl version --client


Install Helm using chocolatey

choco install kubernetes-helm -y

Upgrade Helm

choco upgrade kubernetes-helm -f -y

Add Helm to ‘Path’ environment variable

Check if Helm was istalled successfully (open PowerShell or cmd)

# you might need to restart your cmd/Cmder/Git Bash/PowerShell
helm version

Connect Cmder to Azure

Login to Azure

az aks login

Using Cmder to Interact with AKS Cluster

# if you are not logged in yet
az aks login

# get aks credential
az aks get-credentials --resource-group xyz-rg --name xyz-aks-cluster

AKS cluster Access Control

Once authenticated into AKS cluster, now execute kubectl commands

# make sure you set the correct namespace
kubectl config view --minify | grep namespace  # check namespace, for default namespace no value (empty) might be shown
kubectl config set-context --current --namespace xyz # set namespace

# Nodes
kubectl get nodes

# Pods
kubectl get pods

# Services
kubectl get svc

Installing nodejs and npm


Check if nodejs is laready installed or not

node -v 


# Open Git bash or PowerShell as Admin
choco install nodejs-lts -y
choco install nodejs-lts -y --force

Install specific version

# Open Git bash or PowerShell as Admin
choco install nodejs-lts --version=12.22.9 -y


# Update to if already installed
choco upgrade nodejs-lts

Uninstall (you might want to install specific version)

choco uninstall nodejs-lts
choco uninstall nodejs
choco uninstall nodejs --version=17.2.0

Check correct nodejs version is installed

node -v 

Install npm

# check version
npm -v

# install
npm i -g npm

# check version
npm -v

Installing Angular CLI


Global installation

npm uninstall -g @angular/cli
npm cache clean --force
npm cache verify
npm install -g @angular/cli@latest

Local installation: Go to the priject folder and install local with --save-dev

rm -rf node_modules dist 
npm install --save-dev @angular/cli@latest
npm i 
ng update @angular/cli 
ng update @angular/core
npm install --save-dev @angular-devkit/build-angular

Install specific version

npm install -g @angular/cli@11.2.14

npm install --save-dev @angular/cli@11.2.14

Check version

ng version

Uninstall Angular CLI

npm uninstall -g @angular/cli
npm uninstall @angular/cli
npm cache clean --force

# If you installed specific version
# i.e. version 11.2.11
npm uninstall -g @angular/cli@11.2.11
npm uninstall @angular/cli@11.2.11
npm cache clean --force

Installing jq

Make sure chocolatey is installed (see above)

choco install jq -y
# flag '-y' for accepting all


# Check if already installed
openssl version

# Install
choco install openssl