For system, network and cloud administrators

How to change current PowerShell execution script policy

In order for PowerShell scripts to be run, a less restrictive policy must be set. Like “Remote signed”, for example. In order to change the current PowerShell execution script policy to remote signed for the current user, type:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

How to check current PowerShell script execution policy

In order to determine the current PowerShell script execution policy type:

Get-ExecutionPolicy -List


How to check your PowerShell version

Within a PowerShell session type:

$PSVersionTable.PSVersion

or

pwsh -ver

How to verify if the Az PowerShell module is installed and imported

Az stands for the formal Azure PowerShell module containing cmdlets for Azure features. The following PowerShell code will search for the Az module and if it will not find it installed, it will with all of its dependencies. And then, it ill import it into the session.

if (-not (Get-Module Az -ListAvailable)) {
 Install-Module Az -Scope CurrentUser -Force -Verbose
 Import-Module -Name Az -Verbose
}
else { 
 Import-Module -Name Az -Verbose
}

How to schedule Windows processes/applications to stop/shutdown via PowerShell

I wanted to schedule turning off/shutting down Windows processes/applications because as time passes during my day at my computer, I open more and more applications and they get crowded in my workspace. This is why, I decided to create a PowerShell script that I would execute as soon as I’ve opened my computer. A form of a scheduler that stops applications while I’m working at my computer.

And the script is a pretty easy one. Basically, the script consists of 2 commands: one command that tells the script to “wait” X seconds and a 2nd command that will actually stop/shutdown the Windows process/application that you need.