What is the exact code you’re trying to run?
This works for me:
$AllADgroups = Get-Content C:\Users\Administrator\Desktop\Test.txt
FOREACH ($Adgroup in $AllADgroups)
{$Group = $Adgroup
$Users = Get-AdGroupMember –Identity $Group
Write-output $AdGroup $Users.count
}
Network Configuration Operators
0
Remote Desktop Users
0
Replicator
0
Backup Operators
0
Print Operators
0
Guests
2
Users
3
From: stuart <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Date: Thursday, May 28, 2015 at 7:03 AM
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Subject: Re: [mssms] OT Powershell - again
$AllADgroups = Get-Content ‘path to your TXT file’
FOREACH ($Adgroup in $AllADgroups)
{$Group = $Adgroup
$Users = Get-AdGroupMember – Identiy $ADGroup
Write-output $AdGroup $Users.count
}
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be
used for urgent or sensitive issues