Anton Kruglov Anton Kruglov - 6 months ago 32
PowerShell Question

How to access a Class Defined In A Module From Outside A Module?

I cannot access one class from another. Classes are defined in different files.

Class Foo { static [string]$data }

using module ".\foo.ps1"
class Bar {
Bar() {
[Foo]::data="test" #not working
[Foo]::data="test" #works


Posting as an answer so this doesn't go unanswered (credit to PetSerAl).

Rename foo.ps1 to foo.psm1 so that PowerShell knows it's a module.