/
01_install_fas.ps1
72 lines (64 loc) · 2.76 KB
/
01_install_fas.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Set the start Date and Time
Write-Verbose "Setting Script Parameters" -Verbose
$StartDTM = (Get-Date)
# Read the settings in from the config file and set up variables
# Replace these if you are not using MDT
Write-Verbose "Reading Settings File" -Verbose
$MyConfigFileloc = ("$env:Settings\Applications\Settings.xml")
[xml]$MyConfigFile = (Get-Content $MyConfigFileLoc)
# Configure Script Variables
Write-Verbose "Configure Variables" -Verbose
$Vendor = "Citrix"
$Product = "Federated Authentication Service"
$PackageName = "FederatedAuthenticationService_x64"
$InstallerType = "msi"
$Version = $MyConfigFile.Settings.Citrix.Version
$LogPS = "${env:SystemRoot}" + "\Temp\$Vendor $Product $Version PS Wrapper.log"
$LogApp = "${env:SystemRoot}" + "\Temp\$PackageName.log"
$UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp"
$Destination = "$Version\x64\Federated Authentication Service\"
$Computer = "$env:computername" + "$"
# Start the transcript for the install
Start-Transcript $LogPS
# Change to the Citrix FAS Directory of the Media
If (Test-Path $Destination)
{
Write-Verbose "Changing to FAS Install Directory" -Verbose
Set-Location $Destination
} Else {
Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript
Write-Warning "Failed to find or verify $Destination"
Throw "Could not find directory $Destination"
}
# Install the software
Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose
If ((Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode -eq 0)
{
Write-Verbose "Successfully Installed $Vendor $Product $Version" -Verbose
}
else
{
Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript
Write-Warning "Could not install $Vendor $Product $Version"
Throw "Could not install $Vendor $Product $Version"
}
# Install the AD Management Powershell SDK
Write-Verbose "Install AD Management Powershell SDK" -Verbose
Add-WindowsFeature "RSAT-AD-Tools"
# Add the Server to the Enterprise Admins Group
Write-Verbose "Add the Server to the Enterprise Admins Group" -Verbose
ADD-ADGroupMember "Enterprise Admins" –members "$Computer"
# Stop Logging
Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript