Skip to content

Instantly share code, notes, and snippets.

@trauber
Created September 12, 2015 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trauber/7159aaf89eb625bdf636 to your computer and use it in GitHub Desktop.
Save trauber/7159aaf89eb625bdf636 to your computer and use it in GitHub Desktop.
Parameterizing Powershell Variables
[CmdletBinding()]
param (
  [string] $Name,
  [int] $Age
)

Write-Host -Object "Hi $Name!","You are $Age years old!";

Then to call the script:

.\test.ps1 -Name Trevor -Age 28;

Parameters don't have to be named. You can use $args[n] instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment