Product Documentation

Scripts to add Windows roles and features prerequisites

Feb 27, 2017

You can use the following scripts to install Windows roles and features prerequisites that are required for Session Recording to work properly. For more information, see Use a script to add Windows roles and features prerequisites.    

Install Prerequisites for Session Recording Administration Copy

<#
.Synopsis
Installs Prereqs for Session Recording Administration
.Description
Supports Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2 and Windows Server 2016.
Install below windows feature on this machine:
-Application Development - ASP.NET 4.5 on Server 2012, Server 2012 R2 and Server 2016, Application Development - ASP.NET on Server 2008 R2
-Security - Windows Authentication
-WCF HTTP Activation
-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"
}

function AddHttpActivation()
{
$loop = 1
while($loop -eq 1)
{
Write-Host "Do you want to install the component -- Session Recording Administrator Logging(y/n)"
$user_choice = Read-Host
if($user_choice -eq "y")
{
Write-Host "The component will be installed,please wait."
if (($system -Like ('*Microsoft Windows Server 2012*')) -or ($system -Like ('*Microsoft Windows Server 2016*')))
{
AddFeatures('NET-WCF-HTTP-Activation45')
$loop = 0
}
if($system -like '*Microsoft Windows Server 2008 R2*')
{
AddFeatures('NET-HTTP-Activation')
$loop = 0
}
}
elseif($user_choice -eq "n")
{
Write-Host "The component won't be installed."
$loop = 0
}
else
{
Write-Host "Your input is illegal, please try again!"
}
}
}

$system = gwmi win32_operatingSystem | select name

if (-not (($system -Like '*Microsoft Windows Server 2016*') -or ($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 features
Import-Module ServerManager

AddHttpActivation

if (($system -Like ('*Microsoft Windows Server 2012*')) -or ($system -Like ('*Microsoft Windows Server 2016*')))
{
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

if ($system -Like '*Microsoft Windows Server 2008 R2*')
{
Write-Host "Please install .NET 4.5.1 or higher manually on this machine."
}

Install Prerequisites for Session Recording Agent Copy

<#
.Synopsis
Installs Prereqs for Session Recording Administration
.Description
Supports Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, 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 features
$system = gwmi win32_operatingSystem | select name

if (-not (($system -Like '*Microsoft Windows Server 2008 R2*') -or ($system -Like '*Microsoft Windows Server 2012*') -or ($system -Like '*Microsoft Windows Server 2016*') -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"
}