Using scripts and DSC to set up a virtual lab.
Presentation for the Singapore PowerShell User Group
15. April 2017
Peter Hahndorf
Solution Architect
Hahndorf Consulting
http://peter.hahndorf.eu
The Basics
Keyboard
TAB, F7
Commands
Command -parameter1 -parameter2 argument1 argument2
Arguments are parameters to real parameters
Always verb-noun combinations, so no dir
or copy
but
get-childitems
and copy-item
.
Aliases
dir, ls are aliases for get-childitems.
get-alias | sort name
Help
get-help Get-History [-detailed] [-full]
get-command
Get-Process | get-member
Providers and drives
Filesystem, Registry are builtin, as extensions: Exchange mailboxes, IIS sites etc.
get-psdrive
set-location HKLM:
sl hkcu: ls, cd into stuff
sl Function:
sl C:
You can add your own drives as subset of existing ones, or even write your
own providers for your application.
Functions, Scripts and Profiles
Functions
function demo {Write-Host "Hello $Args"}
demo "World"
COM, WMI and Dot.Net
COM
Access all the COM goodness on your machine; Windows, Office, your own stuff
$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.Navigate2("http://ix.de")
WMI
Some things are only available through Windows Management Instrumentation
Get-WmiObject -class Win32_LogicalDisk | sort -desc Size | select -first 5 DeviceID, VolumeName, Size | format-table -autosize