Last active
November 14, 2019 20:56
-
-
Save mattmcnabb/eb6e8e26aabc2e4e96b8ee4eaab11c3b to your computer and use it in GitHub Desktop.
Can't quite get these transforms working...
This file contains hidden or 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
# this works, but only if I import with using | |
class StringTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute | |
{ | |
[object] Transform([System.Management.Automation.EngineIntrinsics]$EngineIntrinsics, [object]$InputData) | |
{ | |
return "a different string" | |
} | |
} | |
function Test-StringTransform | |
{ | |
param | |
( | |
[StringTransform()] | |
$String | |
) | |
$String | |
} |
This file contains hidden or 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
# this works with Import-Module | |
class StringTransform : System.Management.Automation.ArgumentTransformationAttribute | |
{ | |
[object] Transform([System.Management.Automation.EngineIntrinsics]$EngineIntrinsics, [object]$InputData) | |
{ | |
return "a different string" | |
} | |
} | |
function Test-StringTransform | |
{ | |
param | |
( | |
[StringTransform()] | |
$String | |
) | |
$String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment