找到软件包所在的 SCCM 分发点

Find the SCCM Distribution point where the software packages reside

我们正在尝试查找包含 packages/software 的 SCCM 服务器的主机名,该 packages/software 可以通过使用 Get-WMIObject 查询 WMI 来安装在客户端上。换句话说,当您使用 \SCCMPackageServer\SWD\Packagex.

这样的资源管理器浏览它时,托管包共享的服务器 (SCCMPackageServer)

获取client的详细信息如下查询没有问题:

$ComputerName = 'MyWin7Machine'
$WMIParams = @{
    ComputerName = $SCCMServer
    Namespace    = 'root\SMS\site_SITEID'
}
$Client = Get-WmiObject @WMIParams -Query "select * from sms_r_system where Name='$ComputerName'"

解决方案(感谢 Narcis):

$Client = Get-WmiObject @WMIParams -Query "SELECT * FROM SMS_R_System WHERE Name='$Computer' AND IPSubnets != ''"
Write-Verbose "Computer '$($Client.Name)', IPSubnets '$($Client.IPSubnets)'"

$Result = Foreach ($S in ($Client.IPSubnets | where {($_ -NE '192.168.1.0') -and ($_ -NE '0.0.0.0') -and 
    ($_ -NE '128.0.0.0') -and ($_ -NE '169.254.0.0') -and ($_ -NE '64.0.0.0')})) {
    Write-Verbose "Check IP '$S'"
    Get-WmiObject @WMIParams -Query "SELECT Displayname, SiteSystems, Value, DefaultSiteCode FROM SMS_Boundary WHERE Value = '$S'"
}

$Result | Select-Object -ExpandProperty SiteSystems -Unique

根据您提供的详细信息,下面的脚本将 return 预期的分发点列表,其中应该存在可供他们使用的包(为此他们必须有部署)。根据您提供的代码示例,我假设您依赖广告站点边界。此外,您需要在安装了 SMS_Provider 角色的计算机上 运行。

# Define main variables:
$site = (Get-WmiObject -Namespace "ROOT\SMS" -Query "Select * from SMS_ProviderLocation" | Select-Object -First 1).SiteCode

$SCCMConsoleInstallDir = (Get-ItemProperty "hklm:\software\WOW6432Node\Microsoft\ConfigMgr10\setup")."UI Installation Directory"
Import-Module "$SCCMConsoleInstallDir\bin\ConfigurationManager.psd1"
cd ($site + ":")

$ClientName = "MyWin7Machine"
$ClientObject = Get-WmiObject -Namespace "ROOT\SMS\site_$site" -Query "select * from SMS_R_System" | Where {$_.ADSiteName -ne $null -and $_.Name -eq $ClientName}
$ClientADSite = $ClientObject.ADSiteName

$ClientBoundary = Get-CMBoundary | Where {$_.DisplayName -like "*$ClientADSite"}

$DPs = $ClientBoundary.SiteSystems

Write-Host "The list of Distribution Points associated with the client $ClientName is the following:"
Write-Host "$DPs"

此信息在 SCCM 控制台中也可用,并且是可配置的。如果您要遵循特定的包,那是一个完全不同的主题,SCCM 在内部使用内容位置请求。它们 return 以及所请求包裹的位置列表;从 LOCAL DP 开始,然后继续使用 FALLBACK DP,具体取决于 CLR 的类型。