Way of the Warrior Scripter

Way of the Warrior Scripter

  1. Create scripts to automate common tasks

  2. Add parameters to scripts

  3. Reuse code with functions

  4. Share code using modules

Slowly but surely you are becoming a

PowerShell professional

Assumption 1

You know pipelines and filtering:

Get-ChildItem -Path C:\Windows\System32 -File |
    Where-Object { $_.Extension } |
    Select-Object -Property Extension,Size |
    Group-Object -Property Extension -NoElement |
    Sort-Object -Property Count -Descending

An array or objects is similar to a database table

Remember: Everything is an object

Assumption 2

You know how to help yourself:

Get-ChildItem -?
Get-Help Get-ChildItem -Full
Get-Command *-Item
'some_string' | Get-Member

Jeffrey Snover’s favourite cmdlet is Get-Help

Run Update-Help once in a while

Assumption 3

You know how to write functions:

function ConvertTo-Base64 {
  [CmdletBinding()]
  param(
    [Parameter(Mandatory)]
    [ValidateNotNullOrEmpty()]
    [string]$Data
  )

  [Convert]::ToBase64String(
    [System.Text.Encoding]::UTF8.GetBytes($Item)
  )
}

Naming scheme is Verb-Noun (singular)

Get-Verb displays approved verbs