Get-Content Only Outputting Last Line

21 Views Asked by At

In my following code, I want it to output each AD group. However, it is only outputting the last AD group listed in the text file. How can I output each AD group?

$ADs = Get-Content -Path C:\Users\username\Documents\EditADGroupNotes.txt 

foreach ($AD in $ADs){
$ADGroup = Get-ADGroup -Identity $ADs | select name
}
1

There are 1 best solutions below

0
Michael On

@olaf answered this.

Changed to:

Get-ADGroup -Identity $AD | select name