foreach($x in get-cmdevicecollection -name "All Systems -*"){
$u=$x.Name
$z=$x.Name.insert(3," XP ")
$u
$z
$rule="WinXP"
$Find="Microsoft Windows NT Workstation 5.1"
$query= "select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like '"+$find+"'"
$Schedule = New-CMSchedule –RecurInterval Days –RecurCount 1
New-CMDeviceCollection –Name $z –LimitingCollectionName $u –RefreshSchedule $Schedule -RefreshType "periodic"
Add-CMDeviceCollectionQueryMembershipRule -RuleName $rule -Collectionname $z -QueryExpression $query
}
Friday, December 6, 2013
SCCM 2012 Automated Collections in Powershell
The following code generates device collections of XP Systems from a series of All System - dept name collections. (IE all XP machines in finance dept, All XP machines in Sales)
Labels:
Powershell,
SCCM 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment