Remove SCCM Distribution Point Using Powershell Script

In this post we will see how to remove SCCM distribution point using PowerShell script. From past few weeks I have been working on PowerShell a lot. I see it’s very interesting and makes our job easy.

In my previous post I covered the installation of distribution point using powershell script. The script is available for download here. The script is really simple and easy to use. We basically make use of Remove-CMDistributionPoint cmdlet. Therefore using this cmdlet we uninstall distribution point.

In addition to that this cmdlet supports the common parameters such as -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. Most of all ensure you are running SCCM 2012 R2 SP1 and above for this script to work.

I have tested this script on Configuration Manager current branch versions 1511, 1606, 1610, 1702, 1706, 1710, 1802, 1806, 1810, 1902, 1910, 2002. The script to uninstall SCCM distribution point is available for download here.

Remove SCCM Distribution Point Using Powershell Script

This script removes a distribution point by using a site code and site system role. So before you use this script, specify the following values in the script.

$SiteCode – Provide your site code (3 alphanumeric characters).

$DistributionPoint – Specify the server FQDN from where you want to uninstall DP role.

Script Explanation

Remove-CMDistributionPoint – Removes a distribution point.

-Force – Runs the command without asking for user confirmation.

Copy the below script into a notepad and save it as filename.ps1 extension.

< #.SYNOPSIS
Remove Distribution Point role using PowerShell Script

.DESCRIPTION 
This scripts lets you uninstall SCCM Distribution Point

.PARAMETER DistributionPoint
This is the server name from which you would be uninstalling Distribution Point role.

.PARAMETER SiteCode
This is 3 letter site code.

.NOTES
Version: 1.0
Published Date: 10-Dec-2016
Updated Date: 21-Apr-2020
Author: Prajwal Desai
Website: https://www.prajwaldesai.com
#>

#Load the Configuration Manager Module
import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1')
$Drive = Get-PSDrive -PSProvider CMSite
CD "$($Drive):"

#Site Code and Distribution Point Server Information
$SiteCode = 'IND'
$DistributionPoint = 'WIN2016.PRAJWAL.LOCAL'

#Check if the DP server is alive
Test-Connection -ComputerName $DistributionPoint -quiet

#Remove Distribution Point Role
write-host -ForegroundColor Green "The Distribution Point Role is being uninstalled on $DistributionPoint"
Remove-CMDistributionPoint -Force -SiteCode $SiteCode -SiteSystemServerName $DistributionPoint

Open the script using Powershell ISE. Substitute site code and distribution point values in the script. Save the script and then run the script. If the distribution point server is online, you will see result as True. In the next step you see the distribution point role is uninstalled from the server.

Remove SCCM Distribution Point Using Powershell Script
Remove SCCM Distribution Point Using Powershell Script

If you have any questions regarding this script, mention it in the comments.

Related Posts
guest
8 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Richard Crews

Final product for using a CSV with “Computer” as a header:

#Site Code and Distribution Point Server Information

$SiteCode = ‘IND’

$CSVin = “C:\Scripts\Remove-CMDistributionPoint\RemoteDP.csv”

#Get the content of the CSV file

$Computers = Import-Csv $CSVin

#Loop through each Device and perform actions

Foreach ($Computer in $Computers) {

  #Check if the DP server is alive

  Test-Connection -ComputerName $Computer -quiet

  #Remove Distribution Point Role

  write-host -ForegroundColor Green “The Distribution Point Role is being uninstalled on $Computer”

   

Richard Crews

This wasn’t reliable for me but after a little tweak this ran through 220 DP role removals: <# .SYNOPSIS Remove Distribution Point role using PowerShell Script .DESCRIPTION  This scripts lets you uninstall SCCM Distribution Point .PARAMETER DistributionPoint This is the server name from which you would be uninstalling Distribution Point role. .PARAMETER SiteCode This is 3 letter site code. .NOTES Version: 1.0 Published Date: 10-Dec-2016 Updated Date: 21-Apr-2020 Author: Prajwal Desai Website: https://www.prajwaldesai.com #> #Load the Configuration Manager Module import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + ‘\ConfigurationManager.psd1’) $Drive = Get-PSDrive -PSProvider CMSite CD “$($Drive):” #Site Code and Distribution Point Server Information $SiteCode = ‘ABC’… Read more »

Richard Crews

I’ve been referencing your site for years now. This is a great help! I am a PS noob but I hope to get this working with a CSV because I have to remove the DP role from over 200 workstations.

BTW, there is a space after the lesser than sign. I changed:

< #.SYNOPSIS

to:

<#

.SYNOPSIS

Maheswara reddy kesu

How to remove site system?

Richard Crews

This question is in reference to the Site System role that SCCM removes on its own after a period of time.You are not able to remove it by design.

Ahmed Essam

What about if i want to remove about 240 DP

Ayrton Walter

Hello Prajwal!

What if we are trying to discontinue/uninstall permanently offline DPs?
Is the same procedure applicable?

Regards

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More