Hello,
I have been working through issues with automation and modules for a few days, but no matter what I try I can't get a variable to export from a function to another function within the same PSM1 file. In this simple example there is no PSD1, and the module is loaded in a folder that is in my env path. I just want to see the variable get called properly from both functions.
I want to execute
Foo -One "VariableOne" -Two "VariableTwo"; bar
Function Foo
{
[CmdletBinding()]
param (
[string[]] $one,
[string[]] $two
)
write-host "var$($one)"
write-output $one
write-host $two
}
Export-ModuleMember -Variable * -Function *
Function Bar
{
[CmdletBinding()]
param (
[string[]]$one,
[string[]]$two
)
write-host "Printing dollar1 in bar function: $($one)."
write-host "Printing dollar2 in bar function: $($two)."
}
Export-ModuleMember -Variable * -Function *
*Update*
It seems like I might need to import-module the variables, but when I add a import-modulemember -variable * or the name right after the export, the powershell script asks me to specify parameters.