官术网_书友最值得收藏!

Installing roles and features using Windows PowerShell

To install server roles and features on more than one server at the same time, or to script role and feature installations in more complex scenarios, using Server Manager is not practical, nor does it provide the desired functionality, such as managing multiple servers at once. This is where Windows PowerShell excels, controlling server with either GUI or Server Core version. PowerShell is a task-based command shell and scripting language developed by Microsoft for the purpose of configuration management and task automation. It is based on the .NET Framework, is open source, and can be installed on Windows, macOS, and Linux platforms. 

To install server roles and features using Windows PowerShell, you need to run a PowerShell session with elevated user rights, unless you are installing them on a remote server.

To list roles and features that are available locally on a server, type Get-WindowsFeature or Get-WindowsFeature -computerName <computer_name>, where <computer_name> represents the name of the remote computer you are connecting to. The roles are listed first, followed by the features. In PowerShell terminology, the term role is not used, only features; cmdlets do not differentiate between the two. The following screenshot shows the output of the Windows PowerShell Get-WindowsFeature command:

To install a server role or a feature type, enter the following command:

Install-WindowsFeature -Name <feature_name> -computerName <computer_name>

To install multiple roles and features, separate values using a comma. The management tools needed to manage installed roles and features will be also installed, and your computer will restart if required once the command completes. The following PowerShell command will install the DNS role and XPS Viewer onto a computer using FQDN SRV1.MCSAGUIDE.LOCAL:

Install-WindowsFeature -Name DNS,XPS-Viewer -ComputerName srv1.mcsacertguide.local -IncludeManagementTools -Restart

To verify the installation, run the Get-WindowsFeature command or open Server Manager. On the All Servers page, right-click on a server and select Add Roles and Features.

If needed, list all currently installed features using Windows PowerShell on a target server with the Get-WindowsFeature command. To uninstall or remove roles and features, type the following command:

Uninstall-WindowsFeature -Name <feature_name> -computerName <computer_name> -Restart.

The -Restart switch is not mandatory, but will initiate a computer restart if this is necessary to complete the removal process.

主站蜘蛛池模板: 独山县| 北碚区| 会泽县| 曲周县| 宁都县| 资源县| 高平市| 谷城县| 旬阳县| 开远市| 崇信县| 太康县| 乌兰县| 葫芦岛市| 明星| 舒兰市| 嘉黎县| 垣曲县| 会宁县| 工布江达县| 阿勒泰市| 永安市| 始兴县| 榆林市| 佛冈县| 长治市| 广州市| 石门县| 工布江达县| 绵阳市| 邻水| 彝良县| 依安县| 芷江| 安徽省| 丹东市| 永和县| 苏尼特左旗| 霍山县| 磴口县| 达州市|