I am trying to filter out some Distribution groups with the following script but it does not seem to be working to allow me to filter based on a specific set of characters in the name -
$dist = ForEach ($group in (Get-DistributionGroup -Filter {name -like "*"}))
{ Get-DistributionGroupMember $group | Select @{Label="Group";Expression={$Group.Name}},@{Label="User";Expression={$_.Name}},SamAccountName
}
$dist | Sort Group,User | Export-CSV c:\scripts\file.csv -NoTypeInformation
Would like to filter - name -like "*Law Clerks". This will take any characters before Law and show me the results.
This code is from Martin 9700 off the Spiceworks website. :)