Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.
This repository was 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

Description

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

variables

Workaround:
Use string formatting operator

Activity

  1. justinhauer commented on Aug 26, 2018

    @justinhauer

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

  2. kborowinski commented on Aug 27, 2018

    @kborowinski
    Author

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

  3. markekraus commented on Oct 1, 2018

    @markekraus
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions