Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matt2005/97735819f074d5828a51f2d886c39ffc to your computer and use it in GitHub Desktop.
Save matt2005/97735819f074d5828a51f2d886c39ffc to your computer and use it in GitHub Desktop.
PowerShell: Add a function with a parameter to an object
$result | Add-Member -MemberType ScriptMethod ExpandString -Value {
[cmdletbinding()]
param(
[Parameter(
Mandatory=$true)]
[string]
$unexpandedValue
)
process{
if($this.ProjectInstance){
return $this.ProjectInstance.ExpandString($unexpandedValue)
}
else{
'project is null'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment