PowerShell – Scope & Tooling Design Guidelines

Example of scope:

$var = 'hello!'

function My-Function {
    Write-Host "In the function; var contains '$var'"
    $var = 'goodbye!'
    Write-Host "In the function; var is now '$var'"

Write-Host "In the script; var is '$var'"
Write-Host "Running the function..."
Write-Host "Function is done."
Write-Host "In the script; var is now '$var'"

Tool design guidelines:
Do one thing, do it well.

  • Retrieve data from somewhere
  • Process data
  • Output data to somewhere
  • Put data into some visual format meant for human consumption