Adam Bertram
Adam Bertram

Reputation: 4198

How can I find all content locations for an SCCM Application or Package

I need a method using preferably the Powershell Configuration Manager module to find either the Distribution Point Group Name or the distribution point names that an application or package is on. If this isn't available in the Configuration Manager module, I'll happily take a solution based on a WMI query.

This seems like a simply question but I've been looking for a half hour and I cannot find any method to easily get this.

Upvotes: 0

Views: 8164

Answers (2)

SCCMOG
SCCMOG

Reputation: 11

Get by Package ID (Can be used for Applications, Packages etc)

$SCCMServer = "CAS or Primary Server here"
$SiteCode= "P01" #Change to your site code for DB name
$PackageID = "Package ID here"
$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

Get by Package Name:

$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

Upvotes: 0

Frian Moral
Frian Moral

Reputation: 31

Try to query from CAS or Primary Site...

$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 will have the list of DP where you package is on with corresponding install status of the package. Package Installation complete is the status if the package is successfully copied in a said DP.

Also, for the database name in the connection string it is usually CM_ then the site code for example CM_S02.

Upvotes: 0

Related Questions