Product Documentation

用于添加 Windows 角色和功能必备项的脚本

Mar 17, 2016

您可以使用以下脚本来安装 Session Recording 正常运行所需的 Windows 角色和功能必备项。 有关详细信息,请参阅使用脚本添加 Windows 角色和功能必备项。 

安装 Session Recording Administration 的必备项 复制

<#
.Synopsis
Installs Prereqs for Session Recording Administration
.Description
Supports Windows Server 2008 R2, Windows Server 2012 and Windows Server 2012 R2.
Install below windows feature on this machine:
-Application Development - ASP.NET 4.5 on Server 2012 and Server 2012 R2, Application Development - ASP.NET on Server 2008 R2
-Security - Windows Authentication
-Management Tools - IIS 6 Management Compatibility
IIS 6 Metabase Compatibility
IIS 6 WMI Compatibility
IIS 6 Scripting Tools
IIS 6 Management Console
-Microsoft Message Queuing (MSMQ), with Active Directory integration disabled, and MSMQ HTTP support enabled.
#>
function AddFeatures($featurename)
{
try
{
$feature=Get-WindowsFeature | ? {$_.DisplayName -eq $featurename -or $_.Name -eq $featurename}
Add-WindowsFeature $feature
}
catch
{
Write-Host "Addition of Windows feature $featurename failed"
Exit 1
}
Write-Host "Addition of Windows feature $featurename succeeded"
}

$system= gwmi win32_operatingSystem | select name

if (-not (($system -Like '*Microsoft Windows Server 2012*') -or ($system -Like '*Microsoft Windows Server 2008 R2*')))
{
Write-Host("This is not a supported server platform. Installation aborted.")
Exit
}

# Start to install Windows feature
Import-Module ServerManager

if ($system -Like '*Microsoft Windows Server 2012*')
{
AddFeatures('Web-Asp-Net45') #ASP.NET 4.5
}
if($system -like '*Microsoft Windows Server 2008 R2*')
{
AddFeatures('Web-Asp-Net') #ASP.NET
}
AddFeatures('Web-Mgmt-Console') #IIS Management Console
AddFeatures('Web-Windows-Auth') # Windows Authentication
AddFeatures('Web-Metabase') #IIS 6 Metabase Compatibility
AddFeatures('Web-WMI') #IIS 6 WMI Compatibility
AddFeatures('Web-Lgcy-Scripting')#IIS 6 Scripting Tools
AddFeatures('Web-Lgcy-Mgmt-Console') #IIS 6 Management Console
AddFeatures('MSMQ-HTTP-Support') #MSMQ HTTP Support

安装 Session Recording Agent 的必备项 复制

<#
.Synopsis
Installs Prereqs for Session Recording Administration
.Description
Supports Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows 7, Windows 8, Windows 8.1 and Windows 10.
Install below windows feature on this machine:
-Microsoft Message Queuing (MSMQ), with Active Directory integration disabled, and MSMQ HTTP support enabled.
#>
function AddFeatures($featurename)
{
try
{
$feature=Get-WindowsFeature | ? {$_.DisplayName -eq $featurename -or $_.Name -eq $featurename}
Add-WindowsFeature $feature
}
catch
{
Write-Host "Addition of Windows feature $featurename failed"
Exit 1
}
Write-Host "Addition of Windows feature $featurename succeeded"
}

# Start to install Windows feature
$system= gwmi win32_operatingSystem | select name

if (-not (($system -Like '*Microsoft Windows Server 2012*') -or ($system -Like '*Microsoft Windows Server 2008 R2*')-or ($system -Like '*Microsoft Windows 7*')-or ($system -Like '*Microsoft Windows 8*')-or ($system -Like '*Microsoft Windows 10*')))
{
Write-Host("This is not a supported platform. Installation aborted.")
Exit
}

if ($system -Like '*Microsoft Windows Server*')
{
Import-Module ServerManager
AddFeatures('MSMQ') #Message Queuing
AddFeatures('MSMQ-HTTP-Support')#MSMQ HTTP Support
}
else
{
try
{
if($system -Like '*Microsoft Windows 7*')
{
dism /online /enable-feature /featurename:IIS-WebServerRole /featurename:IIS-WebServer /featurename:IIS-IIS6ManagementCompatibility /featurename:IIS-Metabase /featurename:IIS-ManagementConsole /featurename:IIS-ApplicationDevelopment /featurename:IIS-NetFxExtensibility /featurename:IIS-ISAPIExtensions /featurename:IIS-CommonHttpFeatures /featurename:IIS-DefaultDocument /featurename:IIS-DirectoryBrowsing /featurename:IIS-HttpErrors /featurename:IIS-HttpRedirect /featurename:IIS-StaticContent /featurename:IIS-HealthAndDiagnostics /featurename:IIS-RequestMonitor /featurename:IIS-Performance /featurename:IIS-HttpCompressionStatic /featurename:IIS-Security /featurename:IIS-RequestFiltering /featurename:IIS-LoggingLibraries /featurename:IIS-HttpTracing
dism /online /enable-feature /featurename:MSMQ-Container
dism /online /enable-feature /featurename:MSMQ-Server
dism /online /enable-feature /featurename:MSMQ-HTTP
}
else
{
dism /online /enable-feature /featurename:MSMQ-HTTP /all
}
}
catch
{
Write-Host "Addition of Windows feature MSMQ HTTP Support failed"
Exit 1
}
write-Host "Addition of Windows feature MSMQ HTTP Support succeeded"
}