locked
Exclude OU in PowerShell Get-ADUser command RRS feed

  • Question

  • Hello there !

    I have a problem and I need your help.

    So, I have to do list with domain users who have roaming profiles but I need to exclude one or more OU from that list.

    I have this:

    Get-ADUser -Filter {profilePath -Like "*"} -Properties profilePath | Format-List -Property Name,SamAccountName
    

     How could I do this ? With LDAPfilter ?

    I really don't know. Please help me with this.

    Regards

    Dominik

     
    Tuesday, December 6, 2016 8:03 AM

All replies

  • Hi Dominik,

    the plainest method I have found is post-retrieval filtering:

    Get-ADUser -Filter {profilePath -Like "*"} -Properties profilePath | ? { $_.DistinguishedName -notlike "*Bad,OU,DistinguishedName" }

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Tuesday, December 6, 2016 8:43 AM
  • Thanks !! 
    Tuesday, December 6, 2016 9:27 AM