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

Chocholatey

Install chocolatey using Windows PowerShell (PowerShell 5.1 comes with Windows by default)

Install using Windows PowerShell

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Install using cmd

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Upgrade Chocholatey

choco upgrade chocolatey

Check Chocholatey version

choco upgrade --noop

Uninstalling: https://community.chocolatey.org/courses/installation/uninstalling

PowerShell

“PowerShell” vs “Windows PowerShell”

Check PowerShell 7 is installed or not

Installing PowerShell Core or PowerShell 7

Using chocolatey (open cmd as administrator, unattended installation)

choco install powershell-core -y

Using cmd (open cmd as administrator, unattended installation, check latest version here)

curl --remote-name --location --url https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/PowerShell-7.3.0-preview.6-win-x64.msi
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

Using Windows PowerShell (open Windows PowerShell as administrator, installation wizard will show up)

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
# Long version of above command: Invoke-Expression "& { $(Invoke-Restmethod https://aka.ms/install-powershell.ps1) } -UseMSI"

Restart PC and check PowerShell Core or PowerShell 7 is installed properly

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: https://www.powershellgallery.com/packages/PowerShellGet
#
# If installation fails, try using follwoing flags (https://github.com/PowerShell/PowerShellGetv2/issues/599)
# -AllowClobber -SkipPublisherCheck
#
# Install-Module -Name PowerShellGet -RequiredVersion 2.2.5 -Force
#
Install-Module PowerShellGet -Repository PSGallery -Force

PowerShell in VS Code

Prerequisites:

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

Link: https://techcommunity.microsoft.com/t5/itops-talk-blog/configure-visual-studio-code-to-run-powershell-for-windows-and/ba-p/283258

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
#
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
#
Uninstall-AzureRm

Using Latest PowerShell in PowerShell ISE

#
# Code snippet taken from: https://github.com/adamdriscoll/Presentations/blob/master/YouTube/Using%20PowerShell%207%20in%20the%20ISE/ps7.ps1
#

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

            $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)

            $Runspace.Open()
            $Runspace
        }

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

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

    $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 https://aka.ms/installazurecliwindows -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

C:\az-cloudshell\cloudshell-launcer.ps1

$startShellType = "/usr/bin/pwsh" # PowerShell, for bash -> "/bin/bash"
$cloudshellImageName = "mcr.microsoft.com/azure-cloudshell"

$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 mcr.microsoft.com/azure-cloudshell $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

Links

Pulumi

Install pulumi using chocolatey

choco install pulumi -y

Check version

pulumi version

Cmder

Install cmder using chocolatey

choco install cmder -y
# choco upgrade cmder

Open Cmder

Kubectl

Install kubectl using chocolatey

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

Check version

kubectl version --client

Helm

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

Prerequisites

Check if nodejs is laready installed or not

node -v 

Install

# 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

# 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

Prerequisites

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

Openssl

#
# Check if already installed
#
openssl version

#
# Install
#
choco install openssl