Configuration Manager 2012 SP1 Find Package from ID with PowerShell

If all you have is the packade ID and want to find out what packade it is you can use this PowerShell script below. 

Save the script as “FindPackage.ps1”, change the variables and run it as the following example:
“FindPackage.ps1 -Id P0100001”

It will return something like this.

Configuration Manager 2012 SP1 Find package from ID with PowerShell

PowerShell Script

Param
(
[Parameter(Mandatory=$True)]
[String]$Id
)
Process
{
# Variables
$CMSiteCode = “P01”
$CMModule = ‘C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1’
$PWDBegin = $PWD
$Find = $FALSE
 
Import-Module $CMModule
$CMSiteCode = $CMSiteCode + “:”
Set-Location $CMSiteCode
 
$ProgramPackageInfo = get-CMPackage -Id $Id
$DriverPackageInfo = get-CMDriverPackage -Id $Id
 
If ($ProgramPackageInfo -ne $NULL)
{
“”
“******************************************”
“This is a Program Package:”
“Package Name: ” + $ProgramPackageInfo.Name
“Package Source Path: ” + $ProgramPackageInfo.PkgSourcePath
“Source Date: ” + $ProgramPackageInfo.SourceDate
“******************************************”
“”
$Find = $TRUE
}
 
If ($DriverPackageInfo -ne $NULL)
{
“”
“******************************************”
“This is a Driver Package:”
“Package Name: ” + $DriverPackageInfo.Name
“Package Source Path: ” + $DriverPackageInfo.PkgSourcePath
“Source Date: ” + $DriverPackageInfo.SourceDate
“******************************************”
“”
$Find = $TRUE
}
 
If ($Find -eq $FALSE)
{
“”
“******************************************”
“No package found”
“******************************************”
“”
}
 
Set-Location $PWDBegin
}

Download

FindPackage

3 Responses to Configuration Manager 2012 SP1 Find Package from ID with PowerShell

  1. Ravi August 21, 2014 at 20:57 #

    I would like to suggest you make this available as a separate text download. if the code is copied in the current form, the quotes are coming thro as special characters and powershell is not accepting them

  2. Claus Lindhardt Christensen May 8, 2017 at 14:29 #

    Fantastic 🙂

  3. BKS June 14, 2017 at 20:02 #

    Brilliant!

Leave a Reply