-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWSUSGroupMembership.ps1
28 lines (21 loc) · 1 KB
/
WSUSGroupMembership.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Get WSUS Group Memberships
# Author: Michael Wood, Willis-Knighton Health System
# Version 1.0
#
# Script should query WSUS server for all registered computers and then enumerate the groups for each computer. The results should be saved to a text file in the format <pc name>,<group1>,<group2>...
#Set variables
#$wsusServer = Read-Host 'Please enter the WSUS server you wish to query.'
$wsusServer = "[wsusServer]"
#Set up $wsus variable
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusServer,$false)
$computers = $wsus.GetComputerTargets()
$groups = $wsus.GetComputerTargetGroups()
$hshGroups = @{}
foreach ($group in $groups) {
New-Variable -Name ("grp"+$group.Name)
$computers = $group.GetComputerTargets()
$hshGroups.Add($group.Name, ($computers | foreach{$_.FullDomainName}))
Remove-Variable -Name ("grp"+$group.Name)
}
$hshGroups.GetEnumerator() | | Export-Csv U:\groups.csv