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 is a systems engineer specializing in global systems management for Dell IT. He has a B.S. in Computer Sciences and Engineering from the Ohio State University and is a Microsoft Most Valuable Professional (MVP) for Microsoft System Center Configuration Manager. Greg coauthored SMS 2003 Recipes: A Problem-Solution Approach (Apress, 2006), Microsoft System Center Configuration Manager Unleashed (Sams, 2009), Microsoft System Center 2012 Configuration Manager Unleashed (Sams, 2012), and Microsoft System Center 2012 Configuration Manager: Administration Cookbook (Packt Publishing, 2012), and Microsoft System Center 2012 Configuration Manager R2 Unleashed (Sams, 2012). Greg is cofounder of the Ohio SMS Users Group, and the Central Texas Systems Management User Group.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: