Application of the week > Application of the Week – Microsoft Teams (Part 2)

Thank you for your feedback and comments on the Application of the Week blog about Microsoft Teams.

Last week I met Edijs Perkums at AppManagEvent in Utrecht. He works for Master Packager and is the writer of the blog post which I referred to in ‘Part 1’. He was very happy about the exposure on his blog and I will tell you about ‘Master Packager‘, which is a beautiful and fast MSI editor, in an other blog.

In ‘Application of the Week – Microsoft Teams Part 1‘ I promised to write about how to use our Liquit PowerShell Module to create the ‘Microsoft Teams’ Launch package discussed in that blog.

First of all you need to install both the Liquit Agent and the Liquit Workspace Powershell Module. Both can be downloaded here. The documentation for this Module can be found online here. Do follow the Liquit Release & Patch twitter feed if you like to receive updates for that module like this one.

The full PowerShell script below can be downloaded here.

Let’s review a few lines of that script. This snippet of PowerShell code is used to authenticate against your Liquit zone, which can either on premise or in a private or public cloud:

Import-Module "C:\Program Files (x86)\Liquit Workspace\PowerShell\3.0\Liquit.Server.PowerShell.dll" -Prefix "Liquit"

$liquitZoneUsername = "local\admin"
$liquitZonePassword = Read-Host "Enter Password" -AsSecureString
$liquitCredentials = New-Object -TypeName
System.Management.Automation.PSCredential -ArgumentList $liquitZoneUsername, $liquitZonePassword
$liquitZone = "https://yourliquitzone.liquit.com"

$teamsiconURL = "https://www.setupcommander.com/ico/microsoftteams.ico"
$teamsiconPath = "c:\temp\microsoftteams.ico"
$teamsPackageName = "Microsoft Teams"
$teamsPackageDisplayName = "Microsoft Teams"
$teamsPackageDescription = "Microsoft Teams"

$liquitContext = Connect-LiquitWorkspace -URI $liquitZone -Credential $liquitCredentials

Then we need an icon for this ‘Microsoft Teams’ package. That’s downloaded from our website and then used for the ‘content’ object’:

$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($teamsiconURL,$teamsiconPath)
$content = New-LiquitContent -Path $teamsiconPath

Then it’s time to create the Package, a snapshot for that package and create a filterset:

$package = New-LiquitPackage -Name $teamsPackageName -Type "Launch" -DisplayName $teamsPackageDisplayName -Description $teamsPackageDescription -Priority 100 -Enabled $true -Offline $True -Web $false -icon $content
$snapshot = New-LiquitPackageSnapshot -Package $package
$filterset = New-LiquitFilterSet -Snapshot $snapshot

Let’s add the first action set which launches “${ProgramFiles32}\Teams Installer\Teams.exe”, only when it’s available on the file system. Hence the filter being added. Starting ‘Teams.exe’ copies the file ‘Update.exe’ to ${LocalAppData}\Microsoft\Teams\:

#first action set
$actionset1 = New-LiquitActionSet -snapshot $snapshot -Type Launch -name 'Check Install Teams' -Enabled $true -Frequency Always -Process Sequential

#define actions for the first action set
$actionset1_action1 = New-LiquitAction -ActionSet $actionset1 -Name 'checkInstall Teams' -Type 'processstart' -Enabled $true -IgnoreErrors $false -Settings @{name = '${ProgramFiles32}\Teams Installer\Teams.exe'; parameters ='--checkInstall --source=default'; wait = $true;} -Context User
$actionset1_action2 = New-LiquitAction -ActionSet $actionset1 -Name 'Delete registry value Teams (HKLM Run)' -Type 'regkeydel' -Enabled $true -IgnoreErrors $false -Settings @{key ='HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run'; name ='Teams';} -Context Device
$actionset1_action1_filterset1 = New-LiquitFilterSet -Action $actionset1_action1
$actionset1_action1_filterset1_filter1 = new-LiquitFilter -FilterSet $actionset1_action1_filterset1 -type fileexists -Settings @{path = "`${ProgramFiles32}\Teams Installer\Teams.exe"; } -Value "true"

Let’s add the second action set which launches ‘Update.exe’ from ‘${LocalAppData}\Microsoft\Teams”, only when it’s available on the file system. Along the way it deletes the unwanted unmanaged ‘Microsoft Teams.lnk’ files in both the current User Desktop directory and the All Users Desktop directory:

#second action set
$actionset2 = New-LiquitActionSet -snapshot $snapshot -Type Launch -name 'Launch Teams.exe' -Enabled $true -Frequency Always -Process Sequential

#define actions for the first action set
$actionset2_action3 = New-LiquitAction -ActionSet $actionset2 -Name 'Delete Microsoft Teams.lnk (Per User)' -Type 'filedelete' -Enabled $true -IgnoreErrors $false -Settings @{path ='${Desktop}\Microsoft Teams.lnk';} -Context User
$actionset2_action3_filterset1 = New-LiquitFilterSet -Action<br> $actionset2_action3
$actionset2_action3_filterset1_filter1 = new-LiquitFilter -FilterSet<br> $actionset2_action3_filterset1 -type fileexists -Settings @{path = "`${Desktop}\Microsoft Teams.lnk";} -Value "true"

$actionset2_action4 = New-LiquitAction -ActionSet $actionset2 -Name 'Delete Microsoft Teams.lnk (Per Machine)' -Type 'filedelete' -Enabled $true -IgnoreErrors $false -Settings @{path ='${CommonDesktop}\Microsoft Teams.lnk';} -Context Device

$actionset2_action4_filterset1 = New-LiquitFilterSet -Action<br> $actionset2_action4
$actionset2_action4_filterset1_filter1 = new-LiquitFilter -FilterSet<br> $actionset2_action4_filterset1 -type fileexists -Settings @{path = "`${CommonDesktop}\Microsoft Teams.lnk"} -Value "true"

$actionset2_action5 = New-LiquitAction -ActionSet $actionset2 -Name 'Start Teams' -Type 'processstart' -Enabled $true -IgnoreErrors $false -Settings @{name = '${LocalAppData}\Microsoft\Teams\Update.exe'; parameters ='--processStart "Teams.exe"';} -Context User

$actionset2_action6 = New-LiquitAction -ActionSet $actionset2 -Name 'Wait 3 seconds' -Type 'wait' -Enabled $true -IgnoreErrors $false -Settings @{seconds ='3';}

$actionset2_action7 = New-LiquitAction -ActionSet $actionset2 -Name 'Delete registry value Teams (HKCU Run)' -Type 'regkeydel' -Enabled $true -IgnoreErrors $false -Settings @{key ='HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run'; name ='com.squirrel.Teams.Teams';} -Context User

$actionset2_action8 = New-LiquitAction -ActionSet $actionset2 -Name 'Launch URL (Web Teams)' -Type 'openurl' -Enabled $true -IgnoreErrors $false -Settings @{url ='https://teams.microsoft.com';}
$actionset2_action8_filterset1 = New-LiquitFilterSet -Action<br> $actionset2_action8
$actionset2_action8_filterset1_filter1 = new-LiquitFilter -FilterSet<br> $actionset2_action8_filterset1 -type fileexists -Settings @{path = "`${LocalAppData}\Microsoft\Teams\Update.exe"} -Value "true"

If you want to move the snapshot for this package into production then use:

#move the snapshot into production
Publish-LiquitPackageSnapshot -Snapshot $snapshot -stage Production 


About the author

Leave a Reply