Reputation: 679
I run into issue when executing the following code snippet in ise
by selecting all and click run:
Import-Module ActiveDirectory
class ADUtil
{
[Microsoft.ActiveDirectory.Management.ADGroup] $Group
}
The type [Microsoft.ActiveDirectory.Management.ADGroup] is unknown. If I execute Import-Module ActiveDirectory
explicit at first, then I can run the class definition without any error.
Upvotes: 1
Views: 275
Reputation: 17064
Correct. Naturally, you have to import the module first, before using any types contained in it.
To make this more usuable, there are 2 possibilities off the top of my head:
#Require -Module ActiveDirectory
Import-Module ActiveDirectory
Upvotes: 1