Skip to content

Latest commit

 

History

History
200 lines (133 loc) · 10.4 KB

README.md

File metadata and controls

200 lines (133 loc) · 10.4 KB

PSCMContentMgmt

Branch Build status Last commit Latest release PowerShell Gallery GitHub
master GitHub Workflow Status (branch) GitHub last commit (branch) GitHub release (latest by date) GitHub Release Date PowerShell Gallery GitHub all releases

PowerShell module used for managing Microsoft Endpoint Manager Configuration Manager distribution point content.

Here are some of the things you can do with it:

  • Query content objects which are distributed to distribution point(s) or distribution point group(s)
  • Compare content objects distributed to distribution point(s) or distribution point group(s)
  • Find content objects in a "distribution failed" state for all or selective distribution points
  • Remove, distribute or redistribute content objects returned by any function to distribution point(s)
  • Find an object in your site by searching on any arbitrary ID (useful when reading logs and want to know what object an ID resolves to)
  • Migrate a distribution point’s content to a new/different distribution point by exporting its content library to prestaged .pkgx files and importing the .pkgx files to the new distribution point
  • Invoke the ContentLibraryCleanup.exe tool

PSCMContentMgmt is a mix of being no more than a wrapper for MEMCM cmdlets or native binaries. Some functions query WMI or invoke WMI methods.

PSCMContentMgmt does not intend to reinvent the wheel from already available cmdlets. Instead it provides a simpler workflow for managing your distribution points by offering:

  • Easy to use pipeline support, so you can easily progress through the motions for tasks such as querying content on a distribution point or distribution point group – perhaps in a particular state (e.g. "distribution failed") – and distributing, redistributing or removing it from another (or the same) distribution point or distribution point group.
  • Consistent property names when dealing with different types of content objects, i.e. the ObjectID property is always PackageID except for Applications/Deployment Types where it is CI_ID (same is true with the -ObjectID parameter for functions that offer it).
  • Functionality which the Configuration Manager module does not provide.

Functions

Requirements

Getting started

Install and import:

Install-Module PSCMContentMgmt -Scope CurrentUser
Import-Module PSCMContentMgmt

Each function will have two parameters to communicate to your environment with:

  • -SiteServer: the FQDN server address of your site server (SMS Provider)
  • -SiteCode: the site code of the environment

Using these parameters once for any function of PSCMContentMgmt enables you to not specify them again. These values are held in memory for as long as the PowerShell session exists.

In other words, if you used Get-DP and passed the parameters -SiteServer and -SiteCode, you do not need to specify them again in subsequent uses of Get-DP, and any other function of PSCMContentMgmt.

If the first function you use after importing PSCMContentMgmt requires -SiteServer and -SiteCode and you have not passed the parameters, you will be prompted for them.

If you want to change the values of -SiteServer or -SiteCode, pass those parameters again for any function and those new values will be used for subsequent calls.

This is intended to provide a fluid user experience where you need not to repeatedly specify these required parameters while using the module interactively. You will notice using Get-Help on any functions of PSCMContentMgmt will indicate these parameters are not mandatory. However the user experience will indicate otherwise. This design choice, which favours user experience, does sacrifice the discoverability of these parameter's mandatory requirement.

Where any of the functions return an object with the property ObjectID, or where a parameter is named -ObjectID, it will always be the PackageID for all content objects (Packages, Driver Packages, Boot Images etc) except for Applications/Deployment Types where it is CI_ID. This enables you to have a property ready to use for Applications with any of the cmdlets from the Configuration Manager module.

Examples

Get-Help "about_PSCMContentMgmt_ExportImport"

To learn more about how to migrate distribution point content using PSCMContentMgmt, please see my SysManSquad blog post or read the help topic Get-Help about_PSCMContentMgmt_ExportImport.


Get-DP -Name "SERVERA%", "SERVERB%" -Exclude "%CMG%"

Return distribution points which have a ServerName property starting with SERVERA or SERVERB, but excluding any that match CMG anywhere in its name.


Get-DP | Get-DPDistributionStatus -DistributionFailed | Group-Object -Property DistributionPoint

Return all distribution points, their associated failed distribution tasks and group the results by distribution point now for an overview.


Get-DP | Get-DPDistributionStatus -DistributionFailed | Start-DPContentRedistribution

Return all distribution points, their associated failed distribution tasks and initiate redistribution for them.


Get-DP -Name "London%" | Get-DPContent

Return all content objects found on distribution points where their ServerName starts with "London".

Note: the same is available for groups with Get-DPGroup and Get-DPGroupContent.


Compare-DPContent -Source "dp1.contoso.com" -Target "dp2.contoso.com"

Return objects which are on dp1.contoso.com but not on dp2.contoso.com.

Note: the same is available for groups with Compare-DPGroupContent.


Compare-DPContent -Source "dp1.contoso.com" -Target "dp2.contoso.com" | Start-DPContentDistribution -DistributionPoint "dp2.contoso.com"

Distribute the missing objects to dp2.contoso.com.

Note: the same is available for groups with Start-DPGroupContentDistribution.


Get-DPContent -DistributionPoint "dp1.contoso.com" -Package | Remove-DPContent

Remove all Packages from a distribution point.

Note: the same is available for groups with Get-DPGroupContent and Remove-DPGroupContent.


Invoke-DPContentLibraryCleanup -DistributionPoint "dp1.contoso.com" -Delete

Invoke the ContentLibraryCleanup.exe tool.


Find-CMObject -ID "ACC00048"

Finds any object which has the PackageID "ACC00048", this includes applications, collections, driver packages, boot images, OS images, OS upgrade images, task sequences and deployment packages.


Find-CMObject -ID "17007122"

Finds any object which has the CI_ID "17007122", this includes applications, deployment types, drivers, configuration items and configuration baselines.


Find-CMObject -ID "ScopeId_B3FF3CC4-0319-4434-9D24-77689C53C615/Application_197d8de7-022d-4c0b-aec4-c339ccc17ba4"

Finds an application which matches the ModelName "ScopeId_B3FF3CC4-0319-4434-9D24-77689C53C615/Application_197d8de7-022d-4c0b-aec4-c339ccc17ba4"

Known issues

  • The Configuration Manager module notoriously returns generic error messages (if any) for most of its cmdlets/functions. Since this module is mostly nothing more than a wrapper for most cmdlets/functions, I just forward those messages on to you so please bear that in mind.
  • Remove-DPContent and Remove-DPGroupContent only removes items that are fully distributed.
  • It is not possible to suppress the output of Export-DPContent (which is essentially just Publish-CMPrestageContent).
  • The functions given by this module are not the most performant method of dealing with distribution point content. Most of the Configuraion Manager cmdlet/functions accept arrays of IDs. Whereas I purposefully chose to call the cmdlets for each object purely for the benefit of giving success/failure results back to the user for each object.

Support

For help, be sure to use Get-Help to check out the About help pages or the comment based help in each of functions (which includes examples). Example commands below if you're unsure:

Get-Help "about_PSCMContentMgmt*"
Get-Help "Find-CMObject" -Detailed

Failing that:

  • If you think you're experiencing, or have found, a bug in PSCMContentMgmt, please open an issue.
  • Ping me on Twitter (@codaamok)
  • Come to the WinAdmins Discord and bug me there, my handle is @acc.