Notes about various things that I wanted to find again later, or a few things that would be useful to others. From “Free eBooks” to links about HashTables and Arrays, there will not be any rhyme or reason to this post. Enjoy.

Free eBooks: 

Historical Trend Reports in Powershell

Where and Foreach Methods

PowerShell Advanced Functions

Kevin Marquette on PowerShell Theory

================

Automatically Store Last Output

================

Hashtables 

Everything you wanted to know about HashTables

================

Arrays 

Everything you wanted to know about arrays

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
##############################################################
    # Method 1
    # Create empty array then use the $variable.add("value") later

$Report = [System.Collections.ArrayList]@()
##############################################################
    # Method 2
    # Create and populate an array then use the $variable.add("value") later

$Report = [System.Collections.ArrayList]("A", "B", "C", "D")
##############################################################
    # Method 3
    # Create and populate an array then use the $variable.add("value") later

[System.Collections.ArrayList]$Report = "I", "J", "K", "L"
##############################################################

    # Methods 2 and 3 are the same just depending on how you want to initate it
    # All 3 methods use the following to add/remove values. 

$Collection = New-Object -TypeName System.Collections.ArrayList
$Random = New-Object -TypeName System.Random

$Collection.Add($Random.Next(0,1000)) | Out-Null 

More examples of System.Collections.ArrayList :

Write PowerShell for Speed

Userful .NET Classes for Powershell

================

Everything you ever wanted to know about the Switch statement

RegEx a Phonenumber 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# $a is the original phonenumber
$a = [int64]'1234567890'

# $b is the pattern we want to force $a into
$b = "{0:###-###-####}" -f $a

# output of our regex
$b

# get the last 4 digits of the number
$b.Substring($b.Length -4)

================

Markdown template for Links 

1
[Title](URL)