12 June 2020

Legacy Distribution Point Cleanup

This script will clean up the legacy items left over after a distribution point has been deleted in the configuration manager console. This is sometimes necessary if the same server is going to be used to re-push the distribution point back down to it. The script will not proceed if the DP registry keys are not present so that it can find where the distribution point directory exists to be deleted. 

You can download the script from my GitHub site.


 <#  
      .SYNOPSIS  
           ConfigMgr Distribution Point Cleanup  
        
      .DESCRIPTION  
           This script will cleanup the remnants of a distribution point after it has been deleted in Configuration Manager. This is sometimes necessary when needing to repush a distribution point to the same server.   
        
      .NOTES  
           ===========================================================================  
           Created with:    SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.142  
           Created on:      6/12/2020 2:01 PM  
           Created by:      Mick Pletcher  
           Filename:        DPCleanup.ps1  
           ===========================================================================  
 #>  
   
 [CmdletBinding()]  
 param ()  
   
 #Uninstall ConfigMgr Client  
 If ((Test-Path ($env:windir + '\ccmsetup\ccmsetup.exe')) -eq $true) {  
   Start-Process ($env:windir + '\ccmsetup\ccmsetup.exe') -ArgumentList "/uninstall" -Wait  
 }  
 #Retrieve the path to the distribution point directories  
 If ((Test-Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\DP') -eq $true) {  
   $ContentLibraryPath = ((Get-ItemProperty -Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\DP').ContentLibraryPath).split('\')[0] + '\'  
 } else {  
   Write-Host 'Cannot find path to distribution point content'  
   Exit 1  
 }  
 #Delete the distribution point directories  
 (Get-ChildItem -Path $ContentLibraryPath | Where-Object {($_.Name -like 'SMS*') -or ($_.Name -like 'SCCM*')}) | ForEach-Object {Remove-item -Path $_.FullName -Recurse -Force}  
 #Delete registry keys associated with ConfigMgr  
 If ((Test-Path "REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS") -eq $true) {  
   Remove-Item -Path "REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS" -Recurse -Force -ErrorAction SilentlyContinue  
 }  
   

Related Posts:

  • Pending Reboot Reporting Recently, I implemented Kent Agerlund's technique for monitoring pending reboots located here. This works great, but I also found out there are additional reboot flags on systems that I wanted to monitor. I must s… Read More
  • Find Maximum Possible Resolution for Each Monitor I have been working on a way that I can ensure the maximum resolution is set on monitors. Every so often, a monitor does not have the resolution set to maximum. I have been trying to figure out a way to set the resolution t… Read More
  • MDT Windows Updates Build Report I found it nice to be able to get a clean, filtered report on what Windows updates got installed during the build process. This allows me to inject those updates into the MDT Packages so they get injected into the image bef… Read More
  • Dell Automatic BIOS, Application, and Driver Updates in Build Recently, the Install Dell Command Update and Flash BIOS in WinPE solution I published stopped working when we purchased the Dell E7280. The Dell Command | Update was installing a driver in the WinPE environment t… Read More
  • Pending Reboot Reporting with Orchestrator As we are implementing the ADR in SCCM for servers, we want to know if systems are pending a reboot without having to log into every server. Thankfully, Kent Agerlund, formulated and posted this awesome solution for tr… Read More

0 comments:

Post a Comment