-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCCM - Computername Collection Membership.ps1
More file actions
24 lines (20 loc) · 1.24 KB
/
SCCM - Computername Collection Membership.ps1
File metadata and controls
24 lines (20 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$SiteCode = "CM1" # Site code
$ProviderMachineName = "sccm.contoso.com" # SMS Provider machine name
# Code to get collections machine is a part of
# https://sccmentor.com/2015/04/16/find-collection-membership-for-a-device-with-powershell/
$hostname = "DemoComputer"
<#
$Collections = (Get-WmiObject -ComputerName $ProviderMachineName -Namespace "Root\SMS\Site_$SiteCode" -Query “SELECT SMS_Collection.* FROM SMS_FullCollectionMembership, SMS_Collection where name = '$hostname' and SMS_FullCollectionMembership.CollectionID = SMS_Collection.CollectionID”)
$Collections | Where-Object {$_.Name -notcontains "Query" } | select name
#>
Get-WmiObject -ComputerName $ProviderMachineName -Namespace "Root\SMS\Site_$SiteCode" `
-Query ("select InstalledLocation,ProductVersion,ProductName,ARPDisplayName,Publisher
from
SMS_R_System
join
SMS_G_SYSTEM_Installed_Software on SMS_R_System.ResourceID =
SMS_G_SYSTEM_Installed_Software.ResourceID
where
SMS_R_SYSTEM.Name= ""$($hostname)"" ”) |
Select-Object -Property Publisher, ARPDisplayName,ProductVersion, InstalledLocation |
Sort-Object Publisher