Hello everyone! I am from Argentina, and i have made an script to:
-Uninstall Classic Teams
-Install TeamsNew
-Copy a shorcut to the start up
-It uses a variable to get the current working directory (i also have the problem tha calling \MSTeams-x64.msix it doesnt works)
-Yo can launch it with SCCM as system
Whit this, we are migrating our users from the Classic Teams, to the New Teams.
Hope it helps!
# =================================================================================================
# Script de Instalacion de SW creado por Diego Martin Nunez (EUT)
# Modelo original creado el 27/09/2021
# V4: Se agregó funcion para logueo reducida 03/03/2023 y modelo resumido
# =================================================================================================
# NOTA: Para ejecutar el script Powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File .\Install.ps1
# |DECLARACION DE VARIABLES
$Producto = "Repair TeamsNew 24033.813.2773.520"
$logfile = "TeamsNew.log"
# $ErrorActionPreference = 'SilentlyContinue'
mkdir "C:\Logs" -ErrorAction SilentlyContinue
function Write-Log
{
Param ([string]$LogString)
$global:fh=(Get-Date).ToString("[dd/MM/yyyy HH:mm:ss]")
Write-Host "$fh, $LogString"
"$fh, $LogString" | Out-File -Append -FilePath "C:\Logs\$Logfile"
}
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
$name = $MyInvocation.MyCommand.Name
Write-host "El directorio actual del script es $dir y $name"
$elevated=([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` [Security.Principal.WindowsBuiltInRole]::Administrator)
Write-Log "Software: $Producto, Equipo: $env:Computername"
Write-Log "Permisos elevados: $elevated, Corriendo como: $ENV:username"
# |ETAPA DE INSTALACION & CUSTOMIZACIONES POST
#Bajar proceso antes de comenzar la instalacion/reinstalacion
Write-Log "Bajar proceso antes de comenzar la instalacion/reinstalacion"
Stop-Process -Name "Teams" -Force -ErrorAction SilentlyContinue
Stop-Process -Name "Ms-teams" -Force -ErrorAction SilentlyContinue
start-sleep 5
Write-Log "Desinstalando Teams Classic"
$AppInfo = Get-CimInstance Win32_Product | where-object {$_.Name -like '*teams*'}
$Ver = $AppInfo.Version
$GUIDS = $AppInfo.IdentifyingNumber
Write-Log "Version: $Ver - GUID: $GUID found"
ForEach ($GUID in $GUIDS) {
$processun1 = start-process "Msiexec.exe" -ArgumentList "/x $GUID /Quiet /Passive /NoRestart" -PassThru -Wait -WindowStyle Hidden
$salidaun1=$processun1.ExitCode
Write-Log "ExitCode Desinstalacion TeamsClassic: $salidaun1"
}
start-sleep 10
#Bajar proceso antes de comenzar la instalacion/reinstalacion
Write-Log "Desinstalando Teams New"
Write-Log "Version actual de TeamsNew antes de la desinstalacion:"
(Get-AppxPackage *MSTeams* -AllUsers).Version | Out-File -Append -FilePath "C:\Logs\$Logfile"
Get-AppxPackage *MSTeams* -AllUsers |Remove-AppxPackage -AllUsers
Write-Log "Version actual de TeamsNew luego de la desinstalacion (no debe figurar ninguna):"
(Get-AppxPackage *MSTeams* -AllUsers).Version | Out-File -Append -FilePath "C:\Logs\$Logfile"
start-sleep 5
start-sleep 10
#Etapa de instalacion
Write-Log "Instalacion"
$process = start-process "$dir\teamsbootstrapper.exe" -ArgumentList "-p -o $dir\MSTeams-x64.msix" -PassThru -Wait -WindowStyle Hidden
$salida=$process.ExitCode
Write-host "Salida: $salida"
start-sleep 5
#Customizaciones
Write-Log "Customizaciones"
copy-item "$dir\Microsoft Teams (work or school).lnk" "C:\Users\Public\Desktop" -Force
copy-item "$dir\Microsoft Teams (work or school).lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" -Force
start-sleep 5
# |ETAPA DE INSTALACION & CUSTOMIZACIONES POST
# |SALIDA CON EL EXIT CODE|=========================================================
if(($salida -eq 0) -or ($salida -eq 3010))
{
Write-Log "Instalacion de $Producto satisfactoria!, ExitCode: $salida" -join ','
}
else
{
Write-Log "Instalacion de $Producto ERRORRRRR!, ExitCode: $salida" -join ','
}
# |SALIDA CON EL EXIT CODE|=========================================================
Write-Log "FIN"
Write-Log "-------------------------------------------------------------------------------------------"
start-sleep 5
exit $salida