Skip to content

Instantly share code, notes, and snippets.

@mattmcnabb
Last active November 14, 2019 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmcnabb/eb6e8e26aabc2e4e96b8ee4eaab11c3b to your computer and use it in GitHub Desktop.
Save mattmcnabb/eb6e8e26aabc2e4e96b8ee4eaab11c3b to your computer and use it in GitHub Desktop.
Can't quite get these transforms working...
# 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 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