Created
February 3, 2014 05:57
-
-
Save sayedihashimi/8779449 to your computer and use it in GitHub Desktop.
PowerShell: Add a function with a parameter to an object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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
@aaroncalderon, you have added the scriptmethod to
$result
but you're trying to invoke it onProjectInstance.