Forum Discussion
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 doesn't work. Has anyone seen this before and know what the solution is?
- LainRobertsonSilver Contributor
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
- wpinedoCopper ContributorNo 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.
- LainRobertsonSilver 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