SCCM设备集合查询:在Intranet中查找所有客户端



我正在尝试为设备集合创建WMI查询,以查找当前在我们的Intranet之外的所有计算机。我可以通过执行:

在PowerShell中执行此操作。

(Get-WmiObject -namespace rootccm -query "select InInternet from ClientInfo").InInternet

,但我找不到SCCM中的适当查询。

在客户端的配置管理器中,您可以看到"连接类型"以及它是否是Interanet或Internet。

有人知道在SCCM查询中是否可以吗?

afaik sccm不会收集连接类型,可能是因为它发生了频率(或者至少可以这样做(。我能想到的唯一服务器端查询是检查最后一个MP是否是启用了Internet的MP之一。例如:

SELECT * FROM SMS_R_System WHERE ResourceID IN ( SELECT ResourceID FROM SMS_G_System_CH_ClientSummary WHERE LastMPServerName IN ('InternetEnabledMP.DMZ.contoso.local','MySecondInternetEnabledMP.DMZ.contoso.local'))"

如果 (Get-WmiObject -namespace rootccm -query "select InInternet from ClientInfo").InInternet可以返回正确的数据,您仍然应该能够使用-computername属性在远程计算机上运行命令来从客户端获得所有结果:

Import-Module 'C:Program Files (x86)Microsoft Configuration ManagerAdminConsolebinConfigurationManager.psd1' 
cd cts:
$devices = (Get-CMDevice -CollectionName "All Desktop and Server Clients").name
Foreach ($device in $devices)
{
   if(Test-Connection -ComputerName $device -Count 1 -Quiet)
    {
        $InInternet = (Get-WmiObject -ComputerName $device -Namespace rootccm -Query 'select InInternet from ClientInfo').InInternet
        $properties = @{'name' = $device; 'IsInternet' = $InInternet}
        $Object = New-Object -TypeName PSObject -Property $properties
        Write-Output $Object
   }else{
       Write-Warning "Try connection to $device failed!"
    }
}

该脚本不是一个完整的脚本,因为它在尝试连接到目标机器以获取属性时没有捕获异常。但是它应该能够说出我在这里的意思,应该能够工作。您可能需要在Admin许可下运行脚本

最新更新