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

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.

主站蜘蛛池模板: 隆安县| 达日县| 永德县| 枣强县| 鄂托克旗| 文安县| 龙胜| 太白县| 仙游县| 德格县| 石狮市| 兰州市| 微山县| 天峻县| 东宁县| 祥云县| 漠河县| 宝鸡市| 扶余县| 柳江县| 黎平县| 竹北市| 将乐县| 扬中市| 金昌市| 青铜峡市| 汝州市| 乌兰县| 河北省| 滁州市| 嘉黎县| 兰溪市| 铜陵市| 增城市| 抚州市| 彭泽县| 永春县| 霍山县| 房产| 泸西县| 上林县|