Microsoft Teams

Microsoft Teams Bootstrapper system-wide bulk installer

There is a new method for installed the "new" Microsoft Teams. It is described athttps://learn.microsoft.com/en-us/microsoftteams/new-teams-bulk-install-client. There are multiple parts to this installer. The first is a bash script that downloads the current available files and checks them against the version number downloaded previously. If it is the same it does nothing but if it is newer it updates the wpkg installer script with the new version number. Then wpkg has to execute a batch file that is using powershell to check if the teams appx file is installed. For this to work you will need to adjust your powershell execution policy to allow locally run powershell scripts. Sorry for the convoluted process here but I couldn't immediately think of a better approach to this problem.

There is no way to do a normal uninstall check for the appx files so the batch and powershell files are being executed and passing exit codes through the chain of scripts back to wpkg.

WPKG microsoft-teams.xml

<?xml version="1.0" encoding="UTF-8"?>

<!--                                                                                                                                                                                                               
Thie file generated from tools\update-microsoft-teams.sh and template_microsoft-teams.xml                                                                                                                          
Manual edits to packages\microsoft-teams.xml will be overwritten.                                                                                                                                                  
-->

<packages:packages
        xmlns:packages="http://www.wpkg.org/packages" xmlns:wpkg="http://www.wpkg.org/wpkg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.wpkg.org/packages ../xsd/packages.xsd" >
<package
  id="microsoft-teams"
  name="Microsoft Teams"
  revision="%PKG_VERSION%"
  reboot="false">

  <variable name="PKG_VERSION" value="24257.205.3165.2029" />

  <check
    type="execute"
    path="%SOFTWARE%\batch_files\check-appx-teams.bat"
    condition="exitcodeequalto"
    value="1" />

  <install cmd='"%SOFTWARE%\microsoft-teams\teamsbootstrapper.exe" -p -o "%SOFTWARE%\microsoft-teams\MSTeams-x64.msix"' />

  <upgrade include='install' />

  <remove cmd='"%SOFTWARE%\microsoft-teams\teamsbootstrapper.exe" -x' />

</package>
</packages:packages>

Automated update script

Here is the script that you use to update the installer packages. You'll need to adjust the paths to match your environment. It works for me but your mileage may vary.

update-microsoft-teams-xml.sh

Just to get an idea how this can be done using bash scripting if your wpkg share is on linux using samba, here is my script which checks if there is a newer version of google chrome. Only then it copies the exe and msix files and creates new xml file from template. It substitutes the __VERSION__ and __MSIKEY__ strings, which are extracted from the msi file. Seems like a quick hack to get the strings out of the MSI file, at least it works at the moment.

#!/bin/bash                                                                                                                                                                                                        

MAINPATH=Path to wpkg
TMPPATH=$MAINPATH/temp
DESTPATH=$MAINPATH/installers/microsoft-teams
TEMPLATE=$MAINPATH/packages/Templates/template_microsoft-teams.xml
FILENAME=microsoft-teams.xml
TEMPFILE=$TMPPATH/$FILENAME
DESTFILE=$MAINPATH/packages/$FILENAME

teams_msix_routine () {
DLFILE=$1
DLSOURCE=$2$DLFILE.msix

cd $TMPPATH
if [ -f $DLFILE.msix ]; then
    rm $DLFILE.msix
    fi

/usr/bin/wget --no-check-certificate $DLSOURCE

RAWSTRINGS=`/usr/bin/unzip -p $DLFILE.msix AppxManifest.xml | /usr/bin/strings | /usr/bin/grep -s -o -E Version=\"[[:digit:]]{5}\.[[:digit:]]{3}\.[[:digit:]]{4}\.[[:digit:]]{4}\" | tr -d 'Version=' | tr -d '"' \
`

echo msix version is $RAWSTRINGS

for k in ${RAWSTRINGS} ; do
    unset SUBSTRING;
    SUBSTRING=`expr match "$k" '\([[:digit:].]\{19\}\)' `
    if [ -n "${SUBSTRING}" ] ; then
       MSTVERSION="$SUBSTRING";
       break
    fi
done

echo Version: $MSTVERSION

    if [ -z "$MSTVERSION" ] ; then
       echo no version found
       exit 2
    fi
# create xml file from template

sed -e "s/__VERSION__/${MSTVERSION}/" <$TEMPLATE  | sed -e "s/__VERSION__/${MSTVERSION}/"  >$TEMPFILE

diff -wB $TEMPFILE $DESTFILE >/dev/null

if [ $? -eq 0 ] ; then
    # no difference                                                                                                                                                                                                
    echo not newer
    rm $DLFILE.msix
    exit 0
fi

   echo copying files

mv $DLFILE.msix $DESTPATH/$DLFILE.msix
cp $TEMPFILE $DESTFILE
}

teamsbootstrapper_routine () {
DLFILE=$1
DLSOURCE=$2$DLFILE.exe

cd $TMPPATH
if [ -f $DLFILE.exe ]; then
    rm $DLFILE.exe
    fi

/usr/bin/wget --no-check-certificate $DLSOURCE

RAWSTRINGS=`/usr/bin/7z l $DLFILE.exe  | /usr/bin/strings | /usr/bin/grep -x "^FileVersion:.*$" | tr "\n" " " `
echo Bootstrapper version is $RAWSTRINGS

for k in ${RAWSTRINGS} ; do
    unset SUBSTRING;
    SUBSTRING=`expr match "$k" '\([[:digit:].]\{11\}\)' `
    if [ -n "${SUBSTRING}" ] ; then
       TBSVERSION="$SUBSTRING";
       break
    fi
done

echo Version: $TBSVERSION

    if [ -z "$TBSVERSION" ] ; then
       echo no version found
       exit 2
    fi

   echo copying $DLFILE.exe to $DESTPATH/$DLFILE.exe

mv $DLFILE.exe $DESTPATH/$DLFILE.exe
}

teamsbootstrapper_routine "teamsbootstrapper" "https://statics.teams.cdn.office.net/production-teamsprovision/lkg/"
teams_msix_routine "MSTeams-x64" "https://statics.teams.cdn.office.net/production-windows-x64/enterprise/webview2/lkg/"

Template file

This template file is stored under packages/Templates/template_microsoft-teams.xml and is used to update the packages/microsoft-teams.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<!--                                                                                                                                                                                                               
Thie file generated from tools\update-microsoft-teams.sh and template_microsoft-teams.xml                                                                                                                          
Manual edits to packages\microsoft-teams.xml will be overwritten.                                                                                                                                                  
-->
<packages:packages
        xmlns:packages="http://www.wpkg.org/packages" xmlns:wpkg="http://www.wpkg.org/wpkg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.wpkg.org/packages ../xsd/packages.xsd" >
<package
  id="microsoft-teams"
  name="Microsoft Teams"
  revision="%PKG_VERSION%"
  reboot="false">

  <variable name="PKG_VERSION" value="__VERSION__" />

  <check
    type="execute"
    path="%SOFTWARE%\batch_files\check-appx-teams.bat"
    condition="exitcodeequalto"
    value="1" />

  <install cmd='"%SOFTWARE%\microsoft-teams\teamsbootstrapper.exe" -p -o "%SOFTWARE%\microsoft-teams\MSTeams-x64.msix"' />

  <upgrade include='install' />

  <remove cmd='"%SOFTWARE%\microsoft-teams\teamsbootstrapper.exe" -x' />

</package>
</packages:packages>

Batch

This file is exectuted by wpkg and if it returns '1' the package is installed and if it returns '0' it isn't. I've saved this file as "installers/batch_files/check-appx-teams.bat"

Script

%COMSPEC% /c copy /y "%SOFTWARE%\powershell\check-appx-teams.ps1" "C:\Windows\Temp\check-appx-teams.ps1"
%COMSPEC% /c powershell -File "C:\Windows\Temp\check-appx-teams.ps1"
exit /b %ERRORLEVEL%

Powershell

This powershell script is copied to the local machine then executed. I've saved it as 'installers/powershell/check-appx-teams.ps1'. You need to set your system's powershell execution policy to allow this to run.

Script

if ((Get-AppPackage -AllUsers).Name -like "*MSTeams*") {$ECODE=1} else {$ECODE=0}
exit $ECODE

Microsoft Teams - older version of installer procedure

This is a silent installer for the teams all users installer.

Teams for all intents and purposes must run it's own installer for each individual user. Microsoft #1

The teams installer available from Microsoft only installs an installer that gets autorun for each user. https://docs.microsoft.com/en-us/microsoftteams/msi-deployment

There are people doing workarounds for this but it's long and involved.

The installers installer also seems to fork so the file version check (only way to see if it's there, it doesn't show up in uninstall list until it's installed for the user) so some creativity is needed to get around that. Thanks to the java wpkg package dev for the syntax to use powershell to get around it.

The &apos is vitally important and not a mistake don't delete or convert it

WPKG Package

Teams 1.3

<?xml version="1.0" encoding="UTF-8"?>
<packages:packages xmlns:packages="http://www.wpkg.org/packages"
	xmlns:wpkg="http://www.wpkg.org/wpkg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.wpkg.org/packages ../xsd/packages.xsd">

    <package id="microsoft-teams" name="Microsoft Teams" revision="%PKG_VERSION%" reboot="false" priority="100">

        <variable name="PKG_VERSION"     value="1.3.00.21759" />

        <check type="file" condition="versiongreaterorequal" path="C:\Program Files (x86)\Teams Installer\Teams.exe" value="%PKG_VERSION%" />

<!-- watch out for the $apos; it's important and can't be removed, the escaping arount the quotes is also important -->
        <install cmd='powershell -executionpolicy bypass -noprofile -command "Start-Process C:\Windows\System32\msiexec.exe -ArgumentList &apos;/q /i \"%SOFTWARE%\Teams\%PKG_VERSION%\Teams_windows_x64.msi\"&apos;" -wait' />       


        <upgrade include='install' />

        <remove cmd='powershell -executionpolicy bypass -noprofile -command "Start-Process C:\Windows\System32\msiexec.exe -ArgumentList &apos;/q /x \"%SOFTWARE%\Teams\%PKG_VERSION%\Teams_windows_x64.msi"&apos;" -wait' />       
    </package>

</packages:packages>