forked from Mohrpheus78/Evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstall MS Teams-Preview.ps1
158 lines (134 loc) · 6.84 KB
/
Install MS Teams-Preview.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# *****************************************************
# D. Mohrmann, S&L Firmengruppe, Twitter: @mohrpheus78
# Install Software package on your master server/client
# *****************************************************
<#
.SYNOPSIS
This script installs MS-Teams VDI installer on a MCS/PVS master server/client or wherever you want. An old version will first be uninstalled.
.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!
#>
# define Error handling
# note: do not change these values
$global:ErrorActionPreference = "Stop"
if($verbose){ $global:VerbosePreference = "Continue" }
# Variables
$Product = "MS Teams - Preview Release"
#========================================================================================================================================
# 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
#========================================================================================================================================
# FUNCTION MSI Installation
#========================================================================================================================================
function Install-MSIFile {
[CmdletBinding()]
Param(
[parameter(mandatory=$true,ValueFromPipeline=$true,ValueFromPipelinebyPropertyName=$true)]
[ValidateNotNullorEmpty()]
[string]$msiFile,
[parameter()]
[ValidateNotNullorEmpty()]
[string]$targetDir
)
if (!(Test-Path $msiFile)){
throw "Path to MSI file ($msiFile) is invalid. Please check name and path"
}
$arguments = @(
"/i"
"`"$msiFile`""
"ALLUSER=1"
"ALLUSERS=1"
"OPTIONS='noAutoStart=true'"
"/qn"
)
if ($targetDir){
if (!(Test-Path $targetDir)){
throw "Pfad zum Installationsverzeichnis $($targetDir) ist ungültig. Bitte Pfad und Dateinamen überprüfen!"
}
$arguments += "INSTALLDIR=`"$targetDir`""
}
$process = Start-Process -FilePath msiexec.exe -ArgumentList $arguments -Wait -NoNewWindow -PassThru
if ($process.ExitCode -eq 0){
}
else {
Write-Verbose "Installer Exit Code $($process.ExitCode) für Datei $($msifile)"
}
}
#========================================================================================================================================
# Check, if a new version is available
$Version = Get-Content -Path "$PSScriptRoot\$Product\Version.txt"
$Teams = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*Teams Machine*"}).DisplayVersion
IF ($Teams) {$Teams = $Teams.Insert(5,'0')}
IF ($Teams -ne $Version) {
# Uninstalling MS Teams
IF (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where DisplayName -like "*Teams Machine*") {
Write-Host -ForegroundColor Yellow "Uninstalling $Product"
DS_WriteLog "I" "Uninstalling $Product" $LogFile
try {
$UninstallTeams = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*Teams Machine*"}).UninstallString
$UninstallTeams = $UninstallTeams -Replace("MsiExec.exe /I","")
Start-Process -FilePath msiexec.exe -ArgumentList "/X $UninstallTeams /qn"
Start-Sleep 20
} catch {
DS_WriteLog "E" "Ein Fehler ist aufgetreten beim Deinstallieren von $Product (error: $($Error[0]))" $LogFile
}
DS_WriteLog "-" "" $LogFile
Write-Host -ForegroundColor Green " ...ready!"
Write-Output ""
}
# MS Teams Installation
Write-Host -ForegroundColor Yellow "Installing $Product"
DS_WriteLog "I" "Installing $Product" $LogFile
try {
"$PSScriptRoot\$Product\Teams_windows_x64.msi" | Install-MSIFile
} catch {
DS_WriteLog "E" "Error installing $Product (error: $($Error[0]))" $LogFile
}
DS_WriteLog "-" "" $LogFile
# Configure Teams Settings with json template, template must exist
# copy-item -Path "$PSScriptRoot\$Product\desktop-config.json" -Destination "C:\USers\Default\AppData\Roaming\Microsoft\Teams"
# Prevents MS Teams from starting at logon
Start-Sleep 5
Remove-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run" -Name "Teams" -Force
# Register Teams add-in for Outlook - https://microsoftteams.uservoice.com/forums/555103-public/suggestions/38846044-fix-the-teams-meeting-addin-for-outlook
$appDLLs = (Get-ChildItem -Path "${env:ProgramFiles(x86)}\Microsoft\TeamsMeetingAddin" -Include "Microsoft.Teams.AddinLoader.dll" -Recurse).FullName
$appX64DLL = $appDLLs[0]
$appX86DLL = $appDLLs[1]
Start-Process "$env:WinDir\SysWOW64\regsvr32.exe" -ArgumentList "/s /n /i:user `"$appX64DLL`"" -wait
Start-Process "$env:WinDir\SysWOW64\regsvr32.exe" -ArgumentList "/s /n /i:user `"$appX86DLL`"" -wait
# Register Teams as the chat app for Office
$(
New-Item -Path "HKLM:\SOFTWARE\IM Providers\Teams" -Force
New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\IM Providers\Teams" -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\IM Providers\Teams" -Name "FriendlyName" -Type "String" -Value "Microsoft Teams"
New-ItemProperty -Path "HKLM:\SOFTWARE\IM Providers\Teams" -Name "GUID" -Type "String" -Value "{00425F68-FFC1-445F-8EDF-EF78B84BA1C7}"
New-ItemProperty -Path "HKLM:\SOFTWARE\IM Providers\Teams" -Name "ProcessName" -Type "String" -Value "Teams.exe"
New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\IM Providers\Teams" -Name "FriendlyName" -Type "String" -Value "Microsoft Teams"
New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\IM Providers\Teams" -Name "GUID" -Type "String" -Value "{00425F68-FFC1-445F-8EDF-EF78B84BA1C7}"
New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\IM Providers\Teams" -Name "ProcessName" -Type "String" -Value "Teams.exe"
) | Out-Null
Write-Host -ForegroundColor Green " ...ready!"
Write-Output ""
}
# Stop, if no new version is available
Else {
Write-Host "No Update available for $Product"
Write-Output ""
}