Bug in PowerShell for Exchange Online

PFS IT 21 Reputation points
2021-09-13T16:20:28.627+00:00

Hi

Just a quick question; Is this maybe a bug?

131685-unbenannt.png

With the -Filter parameter, no matching group is found but with "Where" the desired group is found.

Microsoft 365 and Office | Office Online Server
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 123.9K Reputation points MVP Volunteer Moderator
    2021-09-13T17:25:17.123+00:00

    Hi @PFS IT ,

    please try this (not tested):

    Get-DistributionGroup -Filter "Name -eq '$GroupName'"  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 47,906 Reputation points
    2021-09-13T19:33:35.34+00:00

    The -Filter takes a string as an argument, not a code block. It's a good idea to consult the help for a cmdlet (either online or using help cmdlet-name).

    get-distributiongroup

    Follow Andreas' advice. ;-)


  2. Limitless Technology 39,931 Reputation points
    2021-09-14T09:15:10.447+00:00

    Hello PFSIT,

    The Filter parameter indeed takes strings and not code blocks, so it should be between quotes, also would like to introduce you to the tested properties to be applicable for the Filter parameter in Exchange.

    https://learn.microsoft.com/en-us/powershell/exchange/filter-properties?view=exchange-ps

    Hope this may be helpful for you,
    Best regards,

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.