Forum Discussion
AD cmdlets not working
Hi, Walter.
Does the PowerShell window provide any error, warning or information messages?
What edition of PowerShell is running in the ISE, VS Code and the separate window? Windows PowerShell (5.x) or Powershell (7.x)?
Cheers,
Lain
- LainRobertsonJun 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
- LainRobertsonJun 17, 2024Silver Contributor
I can't offer any informed suggestions then.
If you run the following command in the native console, are any of the following set to "SilentlyContinue"?
Get-Variable -Name "*preference";- ErrorActionPreference;
- InformationPreference;
- WarningPreference.
If they are, then set them to "Continue" and re-run your script to see if you get get any messages back.
Otherwise, I can only suggest checking the following locations in Event Viewer to see if it offers any hints as to why nothing at all - even errors or warnings - is being returned.
- Applications and Services/Microsoft/Windows/AppLocker/EXE and Script
- Applications and Services/Microsoft/Windows/PowerShell/Operational
- Applications and Services/PowerShellCore/Operational
- Applications and Services/Windows PowerShell
If there really are zero errors, warning or other forms of feedback, then the only other option is that the script is running without error but simply returning no data to the pipeline.
Cheers,
Lain