widsnet.com
9Jun/170

Find collections with both incremental and full update

Since using incremental and full on a collection is completely useless, remove one or the other. This is one way to find the collections.
RefreshType
1 MANUAL
2 PERIODIC
4 CONSTANT_UPDATE
so RefreshType=6 is both.
https://msdn.microsoft.com/en-us/library/hh442671.aspx

$NameSpace = "root\sms\site_"

Function Get-Container() {
    Param(
        [string]$ContainerID,
        [string]$NameSpace
    )
    $Path = ""
    $Container = Get-WmiObject -Query "SELECT Name,ParentContainerNodeID FROM SMS_ObjectContainerNode WHERE ContainerNodeID='$ContainerID'" -Namespace $NameSpace
    If($Container.ParentContainerNodeID -ne 0) {
        $path += Get-Container -ContainerID $Container.ParentContainerNodeID -NameSpace $NameSpace
    }
    "$path\$($Container.Name)"
}

$Colls = Get-WmiObject -Query "SELECT CollectionID,Name FROM SMS_Collection WHERE RefreshType=6" -Namespace $NameSpace
Foreach ($Coll in $Colls) {
    $Container = Get-WmiObject -Query "SELECT ContainerNodeID FROM SMS_ObjectContainerItem WHERE InstanceKey='$($Coll.CollectionID)'" -Namespace $NameSpace

    If($Container -eq $null) {
        Write-Host "\$($Coll.Name)"
    }
    Else {
        $Container | ForEach-Object{
        $Parent = Get-Container -ContainerID $_.ContainerNodeID -NameSpace $NameSpace
        Write-Host "$Parent\$($Coll.Name) ($($Coll.CollectionID))"
        }
    }
}

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.