Powershell Intro

In recent years it has become necessary to learn Powershell. This is for a number of reasons, but predominately because certain automations are only possible via it. More on that later.

First – how to run powershell … simply windows key + R and powershell.

Or Windows key and start typing powershell – select Windows PowerShell ISE. This provides an IDE.


$single_quoted_string = 'a '
$double_quoted_string = "a string – $x"
Write-Host $single_quote_string
Write-Host $double_quoted_string

# can enforce with [string]

## Integers
[int]$int_one = 1
$int_two = 2
$int_one + $int_two

## Arrays
[array]$arr = @(1,'str_var',5)
$arr += 'add to arr'

## Hash tables
[hashtable]$htab = @{'key1' = 'value1'; 'key2' = 'value2'}


$htab.Add('newkey',”new added variable”)

$htab.Set_Item(“key1”, “mod_val1”)


$a = 1
if ($a -eq 1) {
Write-Host 'a equals 1'
} else {
Write-Host 'a is not equal to 1'

# also possible to elseif

} elseif ($a -eq 3) {


$a = 1

switch ($a) {
1 {“Value 1”}
2 {“Value 2”}
3 {“Value 3”}
default {“Value exceeds threshold.”}

$b = “X365”

switch -wildcard ($b) {
“Z*” {“Val Z”}
“Y*” {“Val Y”}
“X*” {“Val X”}
default {“Val outside parameters.”}

1 – Lessons begin

Welcome to Coding-School.com old school!

Some of the tips, techniques and code freely imparted here, I’ve searched the web previously and come back empty handed. Then set about hand crafting my own solutions – which you get completely for free! 🙂

What gives me the audacity, to think I could possible teach anyone anything Technical! Well here is my 5 line bio:

  • Over 25 years IT work experience. Working with IBM, Compaq, ICL, Dunn and Bradstreet and 2 Banks.
  • Dabbling with LDAP for around 15 years.
  • Dabbling with PHP for around 15 years.
  • Dabbling with Perl for the last 20 years.
  • Over 20 years UNIX Admin. Well you might ask, what the hell has that do to with Coding. IMHO – best Admins code all the time!! 🙂

Cheers and enjoy,