Environment Variables in a Workflow

I’m trying to use environment variables in a workflow:

workflow foobar
{
    [CmdletBinding()]
    Param
    (
        [string]$Path = "$env:HOMEDRIVE\Test\Files"
    )
}

Running this workflow returns the error:

"In a windows PowerShell workflow, parameter defaults may only be simple value types (such as integers) and strings. In addition, the type of the default value must match the type of the parameter."

If I change the parameter to:

C:\Test\Files

That is a solution. But is there a way to use environment variables (in the param block), in a workflow?

Homedrive might not always be C: in my environment.

Not sure what you are trying to achieve but you could use an inline script block inside your workflow like below :-

$HomeDrive = "$env:HOMEDRIVE"

workflow foobar
{
    [CmdletBinding()]
    Param
    (
        [string]$HomeDrivePath="c:\temp"
    )
    inlinescript {

  foreach ($Drive in $using:HomeDrivePath) {

  Test-Path -Path $Drive

  }
  }
}
foobar -HomeDrivePath $HomeDrive