For system, network and cloud administrators
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
In order to determine the current PowerShell script execution policy type:
Get-ExecutionPolicy -List
Within a PowerShell session type:
$PSVersionTable.PSVersion
or
pwsh -ver
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
}
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.