当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 Powershell 脚本删除 SCCM 分发点

作者:精品下载站 日期:2024-12-14 10:55:57 浏览:15 分类:玩电脑

使用 Powershell 脚本删除 SCCM 分发点


在这篇文章中,我们将了解如何使用 PowerShell 脚本删除 SCCM 分发点。从过去的几周以来,我一直在 PowerShell 上进行大量工作。我认为这非常有趣并且使我们的工作变得轻松。

在我的上一篇文章中,我介绍了使用 powershell 脚本安装分发点。该脚本可在此处下载。该脚本非常简单且易于使用。我们基本上使用Remove-CMDistributionPoint cmdlet。因此,我们使用此 cmdlet 卸载分发点。

除此之外,此 cmdlet 支持常见参数,例如 -Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。最重要的是,请确保您运行的是 SCCM 2012 R2 SP1 及更高版本,此脚本才能正常工作。

我已在 Configuration Manager 当前分支版本 1511、1606、1610、1702、1706、1710、1802、1806、1810、1902、1910、2002 上测试了此脚本。用于卸载 SCCM 分发点的脚本可在此处下载。

使用 Powershell 脚本删除 SCCM 分发点

此脚本使用站点代码和站点系统角色删除分发点。因此,在使用此脚本之前,请在脚本中指定以下值。

$SiteCode - 提供您的站点代码(3 个字母数字字符)。

$DistributionPoint - 指定要从中卸载 DP 角色的服务器 FQDN。

脚本说明

Remove-CMDistributionPoint - 删除分发点。

-Force - 运行命令而不要求用户确认。

将以下脚本复制到记事本中并将其另存为 filename.ps1 扩展名。

< #.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

使用 Powershell ISE 打开脚本。替换脚本中的站点代码和分发点值。保存脚本,然后运行该脚本。如果分发点服务器在线,您将看到结果为 True。在下一步中,您会看到分发点角色已从服务器中卸载。

[玩转系统] 使用 Powershell 脚本删除 SCCM 分发点

如果您对此脚本有任何疑问,请在评论中提及。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯