How do I output/append the contents of this foreach loop to a text file?
The following below is not working out.
$Groups = Get-AdGroup -Properties * -filter * | Where {$_.name -like "www*"}
Foreach($G in $Groups)
{
write-host " "
write-host $G.Name
write-host "----------"
get-adgroupmember -Identity $G | select-object -Property SamAccountName
Out-File -filepath C:\test.txt -Append
}
Get-ADGroupMembertoOut-Filewithin the loop?