Example Shell
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

Agenda

  • Intro
  • The Host OS
  • Create new VMs
  • Using custom scripts
  • Using DSC locally
  • Using DSC Server

Host OS

I am using Windows Server 2016 as a host, it boots like a Windows To Go system from an external USB (2 or 3) drive. I use a PowerShell script install and prepare the OS on the USB drive, as this is for testing and evaluation purposes, we can use the 180 day trial version. We can use any normal SATA SSD drive and an USB-3 adapter, we could also connect the drive internally via SATA.

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