1

Is there Powershell command/script that can be setup to run an "update collection memebership" on a specific collection and subcollections? If not Powershell another way besides right click on Collection and manually run an update collection?

CWL
  • 107
  • 2
  • 12

1 Answers1

1

I do it on regular basis using WMI. Simple function that does it:

$YourSCCMServer = '?'
$YourSite = '?'

$WMIStatic = @{
    ComputerName = "$YourSCCMServer"
    NameSpace = "root\sms\site_$YourSite"
}

function Update-Collection {
param ($Filter)
Get-WmiObject @WMIStatic -Class SMS_Collection @PSBoundParameters |
    Invoke-WmiMethod -Name RequestRefresh
}

Update-Collection -Filter "CollectionID = 'SMS00001'"

You just need to fill in the blanks. And write a filter that would include collections you are after.

EDIT: Typo in namespace, not sure where first backslash came from. BTW: for list it's better to include wildcards: -List Collection would not return any results, -List *Collection* would.

BartekB
  • 666
  • 6
  • 9
  • Is this for PS V3.0? I tried this Get-WmiObject @WMIStatic -Class *Collection* -List as your example but I get error Get-WmiObject : Invalid parameter. I checked Namespace and Computername is right. – CWL Mar 13 '13 at 18:26
  • It's not v3 in any way - that was just typo in Namespace, now fixed. – BartekB Mar 13 '13 at 19:17
  • correct my test was using this - just left them off Get-WmiObject @WMIStatic -Class *Collection* -LIST (Yes, removing the \ was the issue) – CWL Mar 13 '13 at 19:48