I need to import the ActiveDirectory module for one of my scripts. When I do this from the command line, running
Import-Module -Name ActiveDirectory
./script.ps1
Everything works just dandy.
But putting the import statement at the top of the script and running the script only, without importing from the command line results in the module not being imported at all, such that this class inside the module is not recognized:
Unable to find type [Microsoft.ActiveDirectory.Management.ADUser]
.
This problem doesn't come up when running the script from the VS code debugger. Why could this be happening?