Skip to content

Instantly share code, notes, and snippets.

@trayburn
Created October 10, 2013 22:11
Show Gist options
  • Save trayburn/6926445 to your computer and use it in GitHub Desktop.
Save trayburn/6926445 to your computer and use it in GitHub Desktop.
PowerShell at DDNUG

Intro to PowerShell for Developers

Welcome

  • Two types of people
    • Unix Shell users
    • Command Prompts are Scary

PowerShell Basics

  • You already have PowerShell
  • Aliases (rm/del, mkdir/md, ls/dir)
  • Verb-Noun and Get-Verb
  • Write-Host
  • Variables ($a = "foo")
    • Variable replacements ("Hello, $a")
  • Ranges (1..10)

PowerShell is Object Oriented

  • How do I get last write time from an 'ls' in shell?
  • Pipeing (|)
  • Filtering (? {})
  • Get-Member
  • Looping (% {})
  • Variables (round 2)
    • Evaluations ("Hello, $($a.Length)")
  • New-Object

PowerShell has a Development Environment

  • ise launches the Integrated Scripting Environment

PowerShell is Dynamic

  • Add-Member for NoteProperty
  • Get-Member has properties not in MSDN

PowerShell loves XML

  • Casting to [xml]
  • Element access via properties
  • The conundrum of leaf values

PowerShell does REST

  • Invoke-RestMethod
  • ConvertTo-Json
  • ConvertFrom-Json

PowerShell drives are CRAZY

  • Get-PSDrive
  • Variable
  • HKLM
  • Env
  • Alias
  • Function

Customizing PowerShell

  • Profiles ($PROFILE)
    • $PROFILE | Format-List -Force
    • Most developers care about 3 profiles
      • PowerShell command prompt
      • ISE
      • NuGet Package Manager Console

Modules

  • Get-Module
  • Get-Module -ListAvailable
  • Import-Module
  • PSGet.net is the NuGet of PowerShell

PowerShell does IIS

  • WebAdministration
  • Copy AppDomains

PowerShell does "make" via "PSake"

  • Import-Module PSake
  • Tasks are run only once
  • Functions can still be declared
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment