SCCM Content Housekeeping
Question
Hi Team, I am looking for a PowerShell script to cleanup SCCM Content from Distribution Point as Well as DP Groups.
Using Remove-CMContentDistribution I am able to clean from DP’s however not able to clean from DP Groups.
Below is the commandline from the script I have used:
Remove-CMContentDistribution -DistributionPointName $DP[0] -ApplicationName $AppList[0].LocalizedDisplayName -Force
Is there a command line/script that can be used specifically to identify the targeted DP’s and DP Group’s for a list of applications and then remove them automatically.
Answers ( 5 )
You can check below two articles:
http://www.pushdeploy.com/2016/08/sccm-powershell-application-content.html?m=1
https://tech.xenit.se/simplify-removing-of-distributed-content-with-powershell/
Hi try below commands
Create a CSV file mentioning the application name inside it.
Also for testing place any 1-2 DP’s in a new distribution point group and name that DP group as ‘All’ or whatever you like and then use below command.
I think the point missing previously is that DP name and DP group name should be used in same command line.
$csv = import-csv C:\Temp\Cleanup\Apps.csv
foreach ($App in $csv.applications) {
Remove-CMContentDistribution -ApplicationName $APP -DistributionPointName Server1.testlab.local -DistributionPointGroupName All -verbose -force
Remove-CMContentDistribution -ApplicationName $APP -DistributionPointName Server2.testlab.local -DistributionPointGroupName All -verbose -force
Remove-CMContentDistribution -ApplicationName $APP -DistributionPointName Server3.testlab.local -DistributionPointGroupName All -verbose -force
Remove-CMContentDistribution -ApplicationName $APP -DistributionPointName Server4.testlab.local -DistributionPointGroupName All -verbose -force
In addition to Ankit’s answer i would like to add few points.
PowerShell script to cleanup SCCM Content from Distribution Point as Well as DP Groups is what the scope i am considering.
As far as i understood.
1. You have Deleted few Packages/Applications in SCCM and now trying to cleanup “Content Library” at DP end to claim space.
2. You have several contents in distributing state and always staying in the same state.
3. Any reason for not using content Library cleanup inbuilt tool for DP?
4. If you could be a little bit more specific what we are trying to do then it will be helpful.
Hi,
Follow the link below by MS which shows the syntax for DP group also in the same command line which you are using.
https://docs.microsoft.com/en-us/powershell/module/configurationmanager/remove-cmcontentdistribution?view=sccm-ps
Have you tried below command?
Remove-CMContentDistribution -DistributionPointGroupName $DP[0] -ApplicationName $AppList[0].LocalizedDisplayName -Force
I have tried the parameter, however did not work for me. Also what syntax can be used to find the DP and DP Group’s targeted for an application using PowerShell.