WindowsCompatibility
WindowsCompatibility copied to clipboard
Variables are not passed to Filter parameter of any cmdlet from ActiveDirectory module
Variables are not passed to Filter parameter on any cmdlet from ActiveDirectory module imported through Import-WinModule:
Workaround: Use string formatting operator
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?
@jdogg89: I was using an elevated Powershell 6.1.0 console on Windows 7 to import ActiveDirectory module.
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'"