1、导出 .XML 配置文件,如 D:\Scripts\DeploymentConfigTemplate.xml:

2、使用记事本创建脚本,并执行脚本:
function Invoke-WindowsFeatureBatchDeployment {
param (
[parameter(mandatory)]
[string[]] $ComputerNames,
[parameter(mandatory)]
[string] $ConfigurationFilePath
)
# Deploy the features on multiple computers simultaneously.
$jobs = @()
foreach($ComputerName in $ComputerNames) {
$jobs += Start-Job -Command {
Install-WindowsFeature -ConfigurationFilePath $using:ConfigurationFilePath -ComputerName $using:ComputerName -Restart
}
}
Receive-Job -Job $jobs -Wait | Select-Object Success, RestartNeeded, ExitCode, FeatureResult
}
# Install Roles and Features
$ServerNames = 'Contoso_01', 'Contoso_02'
Invoke-WindowsFeatureBat

该博客介绍了如何使用 PowerShell 脚本批量在多台服务器上安装 Roles 和 Features。首先,导出配置文件 DeploymentConfigTemplate.xml,然后通过创建并运行 PowerShell 脚本来实现自动化部署。最后,确认安装过程的成功。
627

被折叠的 条评论
为什么被折叠?



