PowerShell / WindowsCompatibility

Module that allows Windows PowerShell Modules to be used from PSCore6
Other
137 stars 33 forks source link

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

Open kborowinski opened 5 years ago

kborowinski commented 5 years ago

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

variables

Workaround: Use string formatting operator

justinhauer commented 5 years ago

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 commented 5 years ago

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

markekraus commented 5 years ago

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'"