如何在Windows中通过PowerShell管理Windows的可选功能

时间:2024-03-28 21:21:03
如何在Windows中通过PowerShell管理Windows的可选功能

Most people know that you can enable or disable the optional Windows features through the Control Panel, but today we’re going to show you how you can do the same thing through the PowerShell command line in Windows 8.

大多数人都知道可以通过“控制面板”启用或禁用可选的Windows功能,但是今天我们将向您展示如何通过Windows 8中的PowerShell命令行执行相同的操作。

从PowerShell管理Windows可选功能 (Manage Windows Optional Features From PowerShell)

The first thing you will want to do is see what features you have enabled, to do this we will need to pass the output of the Get-WindowsOptionalFeature cmdlet down the pipeline, where it can be filtered and formatted:

您要做的第一件事是查看已启用的功能,为此,我们需要将Get-WindowsOptionalFeature cmdlet的输出传递到管道中,在此可以对其进行过滤和格式化:

Get-WindowsOptionalFeature –Online | Where-Object {$_.State –eq “Enabled”} | Format-Table

Get-WindowsOptionalFeature –在线| 哪里对象{$ _。State -eq“ Enabled”} | 格式表

如何在Windows中通过PowerShell管理Windows的可选功能

That will give you a nice tabulated view of what is enabled.

这将为您提供启用状态的漂亮列表视图。

如何在Windows中通过PowerShell管理Windows的可选功能

If you want to see what features are disabled you can use the following:

如果要查看禁用了哪些功能,可以使用以下命令:

Get-WindowsOptionalFeature –Online | Where-Object {$_.State –eq “Disabled”} | Format-Table

Get-WindowsOptionalFeature –在线| 哪里的对象{$ _。State –eq“已禁用”} | 格式表

如何在Windows中通过PowerShell管理Windows的可选功能

If you need to disable a feature you can use the following:

如果需要禁用功能,可以使用以下功能:

Disable-WindowsOptionalFeature –FeatureName NetFx3 –Online

Disable-WindowsOptionalFeature –功能名称NetFx3 –在线

This assumes that the feature that you want to disable is NetFx3.

这假定您要禁用的功能是NetFx3。

如何在Windows中通过PowerShell管理Windows的可选功能

Of course, you will most likely be adding a feature which can be done like so:

当然,您很可能会添加可以通过以下方式完成的功能:

Enable-WindowsOptionalFeature –FeatureName NetFx3 –Online

Enable-WindowsOptionalFeature –功能名称NetFx3 –在线

如何在Windows中通过PowerShell管理Windows的可选功能

That’s all there is to it.

这里的所有都是它的。

翻译自: https://www.howtogeek.com/119059/stupid-geek-tricks-manage-windows-optional-features-from-powershell-in-windows-8/