-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-CollectionsWithoutDeployment.ps1
36 lines (29 loc) · 1.33 KB
/
Get-CollectionsWithoutDeployment.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
29
30
31
32
33
34
35
36
<#
.SYNOPSIS
Returns a CSV with Collections that have no deployments
.DESCRIPTION
Returns a CSV with Collections that have no deployemnts
.EXAMPLE
PS C:\> Get-CollectionsWithDeployment -OutputFile "c:\temp\collections.csv"
.NOTES
Requires sccm-config.json to be set
#>
param (
[Parameter(Mandatory = $true)]
[string]
$OutputFile
)
$config = Get-Content -Path "sccm-config.json" | ConvertFrom-Json
$all_collections = (Get-CimInstance -ComputerName $config.SITE_SERVER_NAME -Namespace root\sms\site_$config.SITE_CODE -class SMS_Collection) | Select-Object CollectionID, Name, ObjectPath, MemberCount, IncrementalEvaluationRunTime
$collections_deployments_ids = (Get-CimInstance -ComputerName $config.SITE_SERVER_NAME -Namespace root\sms\site_$config.SITE_CODE -class SMS_Deploymentinfo).CollectionID | Get-Unique
$data = @()
for ($index = 0; $index -lt $all_collections.Length; $index++ ) {
if (!($collections_deployments_ids -contains $all_collections[$index].CollectionID)) {
$data += New-Object PsObject -property @{
'Name' = $all_collections[$index].Name
'Object Path' = $all_collections[$index].ObjectPath
'Member Count' = $all_collections[$index].MemberCount
}
}
}
$data | Sort-Object -Property Name | Export-csv -Path $OutputFile -NoTypeInformation