In the past (2018) you could use ‘like’ on Get-adgroup, like this:
$adgroups = Get-ADGroup -Filter “name -like ‘ggilje’” | sort name
$data = foreach ($adgroup in $adgroups) {
$members = $adgroup | get-adgroupmember -Recursive | sort name
foreach ($member in $members) {
[PSCustomObject]@{
Group = $adgroup.name
Members = $member.name
MembersFull = $member
}
}
}
$data | export-csv “c:\temp\groupinfo.csv” -NoTypeInformation
So why does this not work anymore Microsoft????
And yes, I DID load the module:
Get-module (get-command Get-ADGroup).Source|Import-Module -Verbose