This should work for you. Just change the SIteCode variable and Server to
your environments.

Import-Module
($env:SMS_Admin_UI_Path.substring(0,$env:SMS_Admin_UI_Path.Length - 4) +
"ConfigurationManager.psd1")
$SiteCode = "PS1"
$Server = "cm12"
CD ("$SiteCode" + ":\")
Get-WmiObject -Namespace "root\sms\site_$SiteCode" -ComputerName $Server
-Query "Select Distinct DefaultIPGateway from
SMS_G_System_Network_Adapter_Configuration where DefaultIPGateway is not
null" | ForEach-Object {
    $Gateway = $_.DefaultIPGateway
    New-CMDeviceCollection -LimitingCollectionName 'All Systems' -Name
$Gateway
    Add-CMDeviceCollectionQueryMembershipRule -CollectionName $Gateway
-QueryExpression "Select * from SMS_R_System inner join
SMS_G_System_Network_Adapter_COnfiguration on
SMS_G_System_Network_Adapter_COnfiguration.ResourceID =
SMS_R_System.ResourceID where
SMS_G_System_Network_Adapter_COnfiguration.DefaultIPGateway = '$Gateway'"
-RuleName "$Gateway"
}


On Fri, Jul 11, 2014 at 12:49 AM, Jason Wallace <[email protected]> wrote:

> Hi folks
>
> A dumb question for this morning but . . .
>
> I am in the midst of a 2007 - 2012 migration.  We want to move devices
> over by IP subnet as there are a large number of branch offices.
>
> I wonder whether someone has a magic script that can allow us to read the
> default gateway from hardware inventory and then create a series of
> collections on that please?
>
> Thanks
>
>


Reply via email to