Forum Discussion
wpinedo
Jun 17, 2024Copper Contributor
AD cmdlets not working
I'm trying to locate users in Active Directory using a function. When I run the code in either ISE or Visual Studio Code, the lookup works. When I run the script in a PowerShell window the lookup doe...
wpinedo
Jun 17, 2024Copper Contributor
No messages. I'm using the ISE to test version 5.x and VS Code to test version 7.x and they both work. Using both a 5.x or a 7.x window doesn't.
LainRobertson
Jun 17, 2024Silver Contributor
One other possibility - and it's so obvious I should have thought of it first, is that the PowerShell window session may not be able to see the module.
I don't know what Active Directory commands you're running as we have no example from you, but you can use Get-Command to see if the commandlet is resolvable:
Get-Command <Active Directory module commandlet>
For example:
Get-Command -Name Get-ADObject;
If you get nothing back from that, then your issue is that the PowerShell session does not know about the ActiveDirectory module.
This can be corroborated by running:
Get-Module -ListAvailable ActiveDirectory;
Cheers,
Lain