Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Variables are not passed to Filter parameter of any cmdlet from ActiveDirectory module #42

Open
kborowinski opened this issue Aug 7, 2018 · 3 comments

Comments

@kborowinski
Copy link

Variables are not passed to Filter parameter on any cmdlet from ActiveDirectory module imported through Import-WinModule:

variables

Workaround:
Use string formatting operator

@justinhauer
Copy link

When I try to import 'import-WinModule' I get access denied. "cannot validate argument on parameter 'session'. @kborowinski were you able to get past this and if so, how?

@kborowinski
Copy link
Author

@Jdogg89: I was using an elevated Powershell 6.1.0 console on Windows 7 to import ActiveDirectory module.

@markekraus
Copy link
Contributor

The script block gets evaluated in the remote scope which will not have your local scope variables in it. I would highly recommend using string evaluated in the local scope for -Filter for a multitude of reasons beyond compatibility with this module.

Try

Get-AdComputer -Filter "Name -like 'PS*' -and LastLogonTimeStamp -lt '$time'"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants