Skip to content

Instantly share code, notes, and snippets.

@seanosullivanuk
Created April 13, 2019 12:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save seanosullivanuk/a0b768bccebad7dee7e269b24e9d61cd to your computer and use it in GitHub Desktop.
Pass a parameter to a PowerShell script
# Pass a parameter to a PowerShell script
# This example requests a single string, stored as a variable
# e.g. .\passparameter.ps1 -FavouriteColour Purple
# If the parameter isn't provided (e.g. .\passparameter.ps1), the script will request it
param (
[string]$FavouriteColour = "$(Read-Host 'Tell me your favourite colour')"
)
Write-Host "You said your favourite colour is $FavouriteColour"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment