Powershell Help RRS feed

  • Question

  • I am using the following to get group membership. However, How can i lmit this to filter a groupname like VPN? If someone could help I would appreciate it....

    Get-ADUser -Filter * -Properties DisplayName,samaccountname,memberof -SearchBase "OU=xxx,OU=xxx" | % {
      New-Object PSObject -Property @{
    UserName = $_.samaccountname
    Groups = ($_.memberof | Get-ADGroup | Select -ExpandProperty Name) -join ","
    } | Select UserName, Groups |Format-Table -AutoSize

    Lee Mossolle

    Thursday, March 12, 2020 11:39 AM

All replies

  • Yes.  You want to use PowerShell help.

    help get-adgroup -online

    This will show you how to filter groups.


    • Edited by jrv Thursday, March 12, 2020 11:55 AM
    Thursday, March 12, 2020 11:55 AM
  • A quick example to filter on groups where the name includes the string VPN anywhere in the value:

    Get-ADGroup -Filter 'Name -Like "*vpn*"'

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Thursday, March 12, 2020 1:45 PM