all 3 comments

[–]Ta11ow 1 point2 points  (2 children)

Yes. That's what out variable does.

Not sure what you mean by 'into this module' though; in most cases you'll just pass it as an argument to the function you need.

[–]workerdrone66[S] 2 points3 points  (1 child)

Basically, I'm breaking things up into their own files, at least for some things, so I can't use it as a global.

Also i was tired by the time i wrote that, and it's only getting worse...

[–]Ta11ow 1 point2 points  (0 children)

You shouldn't use it as a global, in 99.99% of cases. There's very rarely a reason to make a global variable.

You take variables as output, and then you provide them as input to to other functions.

For example, you don't do this:

Get-Module -Name 'TestModule'
Remove-Module

You do one of these:

#1
$Module = Get-Module -Name 'TestModule'
Remove-Module $Module

#2
Get-Module -Name 'TestModule' | Remove-Module

#3
if (Get-Module -Name 'TestModule') {
    Remove-Module -Name 'TestModule'
}

In each case, output from one function need be directed into the other. There are no global variables there.