forked from Mohrpheus78/Evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstall FSLogix.ps1
101 lines (84 loc) · 4.8 KB
/
Install FSLogix.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# *****************************************************
# D. Mohrmann, S&L Firmengruppe, Twitter: @mohrpheus78
# Install Software package on your master server/client
# *****************************************************
<#
.SYNOPSIS
This script installs FSLogix Apps on a MCS/PVS master server/client or wherever you want.
.Description
Use the Software Updater script first, to check if a new version is available! After that use the Software Installer script. If you select this software
package it will be first uninstalled after that it gets installed.
The script compares the software version and will install or update the software. A log file will be created in the 'Install Logs' folder.
.EXAMPLE
.NOTES
Always call this script with the Software Installer script!
Needs a reboot, call a second time after reboot.
#>
# define Error handling
# note: do not change these values
$global:ErrorActionPreference = "Stop"
if($verbose){ $global:VerbosePreference = "Continue" }
# Variables
$Product = "FSLogix"
#========================================================================================================================================
# Logging
$BaseLogDir = "$PSScriptRoot\_Install Logs" # [edit] add the location of your log directory here
$PackageName = "$Product" # [edit] enter the display name of the software (e.g. 'Arcobat Reader' or 'Microsoft Office')
# Global variables
$StartDir = $PSScriptRoot # the directory path of the script currently being executed
$LogDir = (Join-Path $BaseLogDir $PackageName)
$LogFileName = ("$ENV:COMPUTERNAME - $PackageName.log")
$LogFile = Join-path $LogDir $LogFileName
# Create the log directory if it does not exist
if (!(Test-Path $LogDir)) { New-Item -Path $LogDir -ItemType directory | Out-Null }
# Create new log file (overwrite existing one)
New-Item $LogFile -ItemType "file" -force | Out-Null
DS_WriteLog "I" "START SCRIPT - $PackageName" $LogFile
DS_WriteLog "-" "" $LogFile
#========================================================================================================================================
# Check, if a new version is available
$Version = Get-Content -Path "$PSScriptRoot\$Product\Install\Version.txt"
$FSLogix = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Microsoft FSLogix Apps"}).DisplayVersion
IF (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Microsoft FSLogix Apps"}) {
$UninstallFSL = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Microsoft FSLogix Apps"}).UninstallString.replace("/uninstall","")
}
IF (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Microsoft FSLogix Apps RuleEditor"}) {
$UninstallFSLRE = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Microsoft FSLogix Apps RuleEditor"}).UninstallString.replace("/uninstall","")
}
IF ($FSLogix -ne $Version) {
# FSLogix Uninstall
IF (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Microsoft FSLogix Apps"}) {
Write-Host -ForegroundColor Yellow "Uninstalling $Product"
DS_WriteLog "I" "Uninstalling $Product" $LogFile
try {
Start-process $UninstallFSL -ArgumentList '/uninstall /quiet /norestart' –NoNewWindow -Wait
Start-process $UninstallFSLRE -ArgumentList '/uninstall /quiet /norestart' –NoNewWindow -Wait
} catch {
DS_WriteLog "E" "Error Uninstalling $Product (error: $($Error[0]))" $LogFile
}
DS_WriteLog "-" "" $LogFile
Write-Host -ForegroundColor Green "...ready"
Write-Host -ForegroundColor Red "Server needs to reboot, start script again after reboot"
Write-Output "Hit any key to reboot server"
Read-Host
Restart-Computer
}
# FSLogix Install
Write-Host -ForegroundColor Yellow "Installing $Product"
DS_WriteLog "I" "Installing $Product" $LogFile
try {
Start-Process "$PSScriptRoot\$Product\Install\FSLogixAppsSetup.exe" -ArgumentList '/install /norestart /quiet' –NoNewWindow -Wait
Start-Process "$PSScriptRoot\$Product\Install\FSLogixAppsRuleEditorSetup.exe" -ArgumentList '/install /norestart /quiet' –NoNewWindow -Wait
reg add "HKLM\SOFTWARE\FSLogix\Profiles" /v GroupPolicyState /t REG_DWORD /d 0 /f | Out-Null
} catch {
DS_WriteLog "E" "Error installing $Product (error: $($Error[0]))" $LogFile
}
DS_WriteLog "-" "" $LogFile
Write-Host -ForegroundColor Green "...ready"
Write-Output ""
}
# Stop, if no new version is available
Else {
Write-Host "No Update available for $Product"
Write-Output ""
}