-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCCM - function Get-Collections.ps1
More file actions
31 lines (27 loc) · 1.1 KB
/
SCCM - function Get-Collections.ps1
File metadata and controls
31 lines (27 loc) · 1.1 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
25
26
27
28
29
30
31
<#
.NOTES
===========================================================================
Created on: 2022-04-27
Created by: Brian Thorp
===========================================================================
.Description
Two functions written for Migration Tool
#>
function Get-Collections ($hostname)
{
$ResID = (Get-CMDevice -Name "$hostname").ResourceID
$Collections = (gWMI -Namespace "root\SMS\Site_$SiteCode" -Class sms_fullcollectionmembership -Filter "ResourceID = '$($ResID)'").CollectionID
foreach ($Collection in $Collections)
{
Get-CMDeviceCollection -CollectionId $Collection -WarningAction SilentlyContinue | select Name, CollectionID
}
}
function Get-CMCollectionsMemberOf
{
param(
$SiteCode,
$SiteServer,
$ComputerName
)
(Get-WmiObject -ComputerName $SiteServer -Namespace "Root\SMS\Site_$SiteCode" -Query “SELECT SMS_Collection.* FROM SMS_FullCollectionMembership, SMS_Collection where name = '$hostname' and SMS_FullCollectionMembership.CollectionID = SMS_Collection.CollectionID”)
}