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

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.

主站蜘蛛池模板: 南康市| 海盐县| 七台河市| 苏尼特左旗| 尚志市| 扎赉特旗| 广南县| 广汉市| 荣昌县| 吴忠市| 墨竹工卡县| 望奎县| 介休市| 霍邱县| SHOW| 丹东市| 广水市| 寻乌县| 建湖县| 鄂托克旗| 鄂托克旗| 万源市| 池州市| 海林市| 南投市| 五华县| 河北区| 江永县| 天气| 老河口市| 航空| 汪清县| 湖口县| 呼图壁县| 确山县| 巴彦淖尔市| 德令哈市| 内乡县| 比如县| 邛崃市| 伊通|