Welcome to PrajwalDesai.com. This blog has articles on Microsoft Technologies such as SCCM, Azure, Cloud, PowerShell, Security and other technologies.

Remove SCCM Distribution Point Using Powershell Script

0

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 quiet interesting and makes our job easy. In my previous post I showed 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 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. 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
Date: 10-Dec-2016
Author: Prajwal Desai
Website: http://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.