#------添加角色/角色服务------
Import-Module servermanager
$features = get-windowsfeature Net-*,Telnet-*,Web-*
Write-Host " 开始添加角色/角色服务... ..."
foreach($item in $features)
{
if($item.installed -eq $false)
{
Write-Host "添加:" $item.DisplayName
$item | add-windowsfeature
}
}
文章引用自https://www.cnblogs.com/liushen/p/5283377.html
个人备注:
该脚本是通过get-windowsfeature xxx*,xxxx* 找出对应的需要部署IIS的服务、功能、角色。这个查询方式是模糊查询(“*”的作用类似于SQL的like用法),可以通过精确查询来添加单一或批量服务,根据需求而定。
$features = get-windowsfeature Net-*,Telnet-*,Web-*