Skip to content

Instantly share code, notes, and snippets.

@shaneis
Created February 22, 2019 14:58
Show Gist options
  • Save shaneis/0cd417a2964ca4f4582e96eab51590bf to your computer and use it in GitHub Desktop.
Save shaneis/0cd417a2964ca4f4582e96eab51590bf to your computer and use it in GitHub Desktop.
Get-Name with extra for ScriptBlock
function Get-Name {
[CmdletBinding()]
param(
[String]$Name = 'you'
)
'Hello, {0}. Script root is {1}' -f $Name, $PSScriptRoot
}
Get-Name -Name Shane
@shaneis
Copy link
Author

shaneis commented Jan 10, 2021

Yup, looks good to me. Nice one!

I'll say that it may be difficult to get everyone in the company/community to use this style. Especially if they're starting with PowerShell and wondering "Why do I have to do this when I just want to run a script?!"

Overall, though, yup! An absolutely superb way to ensure these scripts are testable

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