Hello.....How can I get this to except my "GroupName" in the second example?
Example 1. This Works
$Results = Get-ADgroup -LDAPFilter "(name=My_Group_Name)" | Select-Object -ExpandProperty "Name"
$Results
Example 2. This doesn't
$GroupName = "My_Group_Name"
$Results = Get-ADgroup -LDAPFilter "(name=$GroupName)" | Select-Object -ExpandProperty "Name"
$Results
Example 3. works but too slow
$Results = get-adgroup -Filter 'GroupCategory -eq "Security" -and GroupScope -eq "Global"' '
| Where-Object {$_.Name -eq "My_Group_Name"}
| Get-ADGroupMember | select name -ExpandProperty "Name"
The quickest search method in my environment is to use the -LDAPFilter instead of -Filter
Thank you