Removing Empty Folders

There’s a “feature” in ConfigMgr 2012 that occurs when you perform the following steps:

  • Send a package to the DP
  • Enable the “Copy the content in this package to a package share on distribution points” checkbox.
  • Clear the “Copy the content in this package to a package share on distribution points” checkbox.

When you clear the checkbox, the contents of the folder on the share are removed, but the root folder (which is named by PackageID) remains.

Normally this wouldn’t be a problem, but we do have a 3rd party integration  to ConfigMgr 2012 that will look for packages on the package share, and since these are empty, we receive unexpected results.  As a result, here’s a simple PowerShell script to remove any empty folders from the smspkgd$ share:


get-childitem d:\smspkgd$  | % { if ((get-childitem -path $_.FullName -recurse | measure-object -property length -sum).sum -eq $null) {$_.Name; remove-item -path $_.FullName}}

Happy Scripting!

About Greg Ramsey
Greg Ramsey, Enterprise Mobility MVP, is a Senior Enterprise Architect at Dell Technologies. He has a B.S. in Computer Sciences and Engineering from Ohio State University and has co-authored many books over the years. Greg is an international speaker, a board member of the Northwest System Center User Group, and the Director of Communications for the Midwest Management Summit.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: