Sulich's Blog

Sulich's Blog

SCCM 2012 Device collections based on Operation Systems

Creating SCCM 2012 device colections based on the operation system:

# Variables
$PWDBegin=$PWD
$CMSiteCode=”001″ # Change this – This should be your site code
$CMModule=’D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1’ # Change this – This should point to the CM module
Import-Module $CMModule
$CMSiteCode = $CMSiteCode+”:”
Set-Location $CMSiteCode
$schedule = New-CMSchedule -RecurInterval Days -RecurCount 7

New-CMDeviceCollection -Name “Windows 8” -LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows 8” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Workstation 6.2%'” -RuleName “Windows 8”

 

New-CMDeviceCollection -Name “Windows 7” -LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows 7” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Workstation 6.1%'” -RuleName “Windows 7”

 

New-CMDeviceCollection -Name “Windows Vista”-LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows Vista” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Workstation 6.0%'” -RuleName “Windows Vista”

New-CMDeviceCollection -Name “Windows XP”-LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows XP” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Workstation 5.1%'” -RuleName “Windows XP”

New-CMDeviceCollection -Name “Windows Server 2012”-LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows Server 2012” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Server 6.2%'” -RuleName “Windows Server 2012”

New-CMDeviceCollection -Name “Windows Server 2012 R2” -LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows Server 2012 R2” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Server 6.3%'” -RuleName “Windows Server 2012 R2”

New-CMDeviceCollection -Name “Windows Server 2016” -LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows Server 2016” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Server 10%'” -RuleName “Windows Server 2016”

New-CMDeviceCollection -Name “Windows Server 2008 R2”-LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows Server 2008 R2” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Server 6.1%'” -RuleName “Windows Server 2008 R2”

New-CMDeviceCollection -Name “Windows Server 2008”-LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows Server 2008” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Server 6.0%'” -RuleName “Windows Server 2008”

New-CMDeviceCollection -Name “Windows Server 2003”-LimitingCollectionName “All Systems” -RefreshSchedule $schedule
Add-CMDeviceCollectionQueryMembershipRule -CollectionName “Windows Server 2003” -QueryExpression “select SMS_R_SYSTEM.ResourceName,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueNameentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘%Microsoft Windows NT Server 5.2%'” -RuleName “Windows Server 2003”
Set-Location $PWDBegin

 

Single Post Navigation

Leave a comment