我需要一种方法,最好使用Powershell Configuration Manager模块来查找应用程序或程序包所在的分发点组名称或分发点名称。如果Configuration Manager模块中没有这个功能,我很乐意根据WMI查询采取解决方案。
这似乎只是一个简单的问题,但我一直在找半小时,我找不到任何方法可以轻易搞定。
答案 0 :(得分:0)
尝试从CAS或主站点查询...
$SCCMServer = "SERVERNAME"
$PackageName = "YOUR PACKAGE TO FIND"
$Query = @"
Select ServerNalPath, InstallStatus from fn_rbac_PackageStatusDistPointsSumm('')
Where PackageID in (Select PackageID from v_Package where Name like '%$PackageName%')
"@
$objConnection = New-Object System.Data.SqlClient.SqlConnection
$objConnection.ConnectionStrng = "Server=$SCCMServer;Database=CM_<Site code>;trusted_connection=true;"
$SQLCmd = New-Object system.Data.SqlClient.SqlCommand $Query, $objConnection
$SQLCmd.Connection.Open()
$dt = New-Object System.Data.DataTable
$dt.Load($SQLCmd.ExecuteReader())
$SQLCmd.Connection.Close()
$ dt将包含打包的DP列表以及包的相应安装状态。如果在所述DP中成功复制了包,则包安装完成是状态。
此外,对于连接字符串中的数据库名称,它通常是CM_,然后是站点代码,例如CM_S02。
答案 1 :(得分:0)
按程序包ID获取(可用于应用程序,程序包等)
$SCCMServer = "CAS or Primary Server here"
$SiteCode= "P01" #Change to your site code for DB name
$PackageID = "JEP001BB"
$Query = @"
SELECT vDDPs.Name, vDDPs.MessageState FROM vSMS_DistributionDPStatus vDDPs
WHERE vDDPs.PackageID = '$PackageID'
"@
$objConnection = New-Object System.Data.SqlClient.SqlConnection
$objConnection.ConnectionString = "Server=$SCCMServer;Database=CM_$SiteCode;trusted_connection=true;"
$SQLCmd = New-Object system.Data.SqlClient.SqlCommand $Query, $objConnection
$SQLCmd.Connection.Open()
$dt = New-Object System.Data.DataTable
$dt.Load($SQLCmd.ExecuteReader())
$SQLCmd.Connection.Close()
$dt
通过软件包名称获取:
$SCCMServer = "CAS or Primary Server here"
$SiteCode= "P01" #Change to your site code for DB name
$PackageName = "Package Name here"
$Query = @"
SELECT vDDPs.Name, vDDPs.MessageState FROM vSMS_DistributionDPStatus vDDPs
WHERE vDDPs.PackageID in (Select PackageID from v_Package where Name like '$PackageName')
"@
$objConnection = New-Object System.Data.SqlClient.SqlConnection
$objConnection.ConnectionString = "Server=$SCCMServer;Database=CM_$SiteCode;trusted_connection=true;"
$SQLCmd = New-Object system.Data.SqlClient.SqlCommand $Query, $objConnection
$SQLCmd.Connection.Open()
$dt = New-Object System.Data.DataTable
$dt.Load($SQLCmd.ExecuteReader())
$SQLCmd.Connection.Close()
$dt