如何使用PowerShell删除Windows功能?
要删除Windows功能,我们可以使用命令Remove-WindowsFeature和功能名称一起使用。
Remove-WindowsFeature Search-Service -Verbose
VERBOSE: Uninstallation started...VERBOSE: Continue with removal?
VERBOSE: Prerequisite processing started...
VERBOSE: Prerequisite processing succeeded.
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {Windows Search Service}
VERBOSE: Uninstallation succeeded.
如果Windows功能具有与Web服务器(IIS)功能相同的管理工具,则可以在命令行中添加该工具。如果服务器需要重新启动,则可以添加-Restart参数。例如,
Remove-WindowsFeature Web-Server -IncludeManagementTools -Restart -Verbose
如果我们检查-Name参数,则它支持字符串数组。这意味着我们可以一起删除多个角色和功能。
help Remove-WindowsFeature -Parameter Name -Name <Feature[]>
删除多个功能以及与-LogPath参数一起在本地计算机上记录输出的示例。
PS C:\Users\Administrator> Remove-WindowsFeature Windows-Server-Backup, Search-Service -LogPath C:\Temp\Uninstallfeatures.txt -VerboseVERBOSE: Uninstallation started...
VERBOSE: Continue with removal?
VERBOSE: Prerequisite processing started...
VERBOSE: Prerequisite processing succeeded.
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {Windows Search Service, Windows Server Ba...
VERBOSE: Uninstallation succeeded.
要删除远程计算机上的Windows功能,您需要使用-ComputerName参数。例如,
Remove-WindowsFeature Windows-Server-Backup, Search-Service -ComputerName Test1-Win2k16 -Verbose
输出结果
PS C:\Scripts\IISRestart> Remove-WindowsFeature Windows-Server-Backup, Search-Service -ComputerName Test1-Win2k16 -VerboseVERBOSE: Uninstallation started...
VERBOSE: Continue with removal?
VERBOSE: Prerequisite processing started...
VERBOSE: Prerequisite processing succeeded.
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {Windows Search Service, Windows Server Ba...
VERBOSE: Uninstallation succeeded.
此-ComputerName参数是字符串参数,而不是如下所示的带有help命令的数组。
help Remove-WindowsFeature -Parameter ComputerName -ComputerName [<String≫]
因此,要从多台计算机中删除Windows功能,我们需要使用foreach循环和-ComputerName参数或通过Invoke-Command。使用Invoke-Command会更容易。
Invoke-Command -ComputerName Test1-Win2k16,Test1-Win2k12 -ScriptBlock{Remove-WindowsFeature Windows-Server-Backup,Search-Service}
上面的命令将确保删除多台远程计算机上的多个功能。
以上是 如何使用PowerShell删除Windows功能? 的全部内容, 来源链接: utcz.com/z/322215.html