Link to home
Start Free TrialLog in
Avatar of String :-)
String :-)Flag for Australia

asked on

Powershell - How to generate a list of computers from multiple groups

$ADGroupName = 'WSUS_Win_Servers_Patching_Z1'
import-module activedirectory
#region Build-Computer-List
(Get-ADGroupMember -Identity $ADGroupName | Sort Name | Select-Object -ExpandProperty Name) -join "`r`n" | Set-Content -Path .\computers.txt -NoNewline -Force


Open in new window


I usually use the above line to build my computer list from an AD Group, however for my next script I need to pull list from multiple groups, Any ideas how I do this.
Cheers
String

ie 

WSUS_Win_Servers_Patching_Z1

Open in new window

WSUS_Win_Servers_Patching_Z2 etc

Open in new window

Open in new window

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of String :-)

ASKER

Perfect that worked very nicely.  Good learning exercise for me too.
Thanks a bunch Footech