I'm trying to write a custom Task, but variables in my scriptblock aren't in the correct scope. #36

AnthonyMastrean opened this Issue May 31, 2012 · 1 comment


None yet

1 participant


I'm trying to write a declarative custom task. Normally, your tasks look like this

Task echo {
    Write-Host "hello, this is my task"

But, if you want to be declarative and separate the declaration and execution of the task, you'll want something like this

Echo-Task hello { param($x)
    $x.message = "hello, this is my task"

Yeah, it's a little verbose for this trivial example, but it's powerful for more complicated tasks. And it's what's happening over in the [Albacore library][al](Rake tasks for .NET & some custom tasks I've written).


oops, this one was created by accident

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