Removing Empty Folders
November 1, 2012 Leave a comment
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!