Microsoft Windows
Active Members
- Joined
- Dec 10, 2024
- Messages
- 23,867
In Powershell (specifically 5.1), I have a custom class Foo, defined in a file like this:Class Foo { ....}And in a script (.ps1 file) I want to use this type for one of the parameters, e.g.
aram( [Foo] $Bar ...The problem is that Param() MUST be the first statement in the script, other than comments or #requires. So how do I tell the script what the definition of Foo is?1. Putting the class definition in a module and "importing" with #requires doesn't work, because #requires doesn't import classes.2. Putting anything above the Param() (such as putting the definition of Foo in a separ
Continue reading...

Continue reading...