Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Define log file path
- $logFilePath = "C:\TEMP\Teams.log"
- # Define the path to the Teams Bootstrapper
- $teamsBootstrapperPath = "\\domain.net\dfs$\Admin\SoftwareRepository\SWD\Microsoft\Teams\teamsbootstrapper.exe"
- # Function to log messages
- function Log-Message {
- param(
- [string]$Message
- )
- Add-Content -Path $logFilePath -Value "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - $Message"
- }
- # Log starting message
- Log-Message "Starting Teams Bootstrapper execution..."
- try {
- # Run Teams Bootstrapper with parameter -p and wait for completion
- Start-Process -FilePath $teamsBootstrapperPath -ArgumentList "-p", "-o", "\\domain.net\dfs$\Admin\SoftwareRepository\SWD\Microsoft\Teams\MSTeams-x64.msix" -Wait -ErrorAction Stop
- Log-Message "Teams Bootstrapper execution completed successfully."
- } catch {
- $errorMessage = "Failed to run Teams Bootstrapper: $_"
- Log-Message $errorMessage
- Write-Host $errorMessage -ForegroundColor Red
- exit 1
- }
- # Define the path to the installer
- $installerPath = "C:\Program Files\WindowsApps\MSTeams_*\MicrosoftTeamsMeetingAddinInstaller.msi"
- # Get the latest version folder
- $teamsFolder = Get-ChildItem -Path "C:\Program Files\WindowsApps\" -Filter "MSTeams_*" -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1
- # Check if Teams folder exists
- if ($teamsFolder) {
- $teamsPath = Join-Path -Path $teamsFolder.FullName -ChildPath "MicrosoftTeamsMeetingAddinInstaller.msi"
- # Get the version number
- try {
- $version = (Get-AppLockerFileInformation -Path $teamsPath | Select-Object -ExpandProperty Publisher).BinaryVersion
- } catch {
- $errorMessage = "Failed to retrieve version information: $_"
- Log-Message $errorMessage
- Write-Host $errorMessage -ForegroundColor Red
- exit 1
- }
- # Define the installation command
- $installCommand = "msiexec.exe /i `"$teamsPath`" ALLUSERS=1 /qn /norestart TARGETDIR=`"C:\Program Files (x86)\Microsoft\TeamsMeetingAddin\$version\`""
- # Execute the installation command
- Log-Message "Installing Teams Meeting Addin version $version..."
- try {
- Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$teamsPath`" ALLUSERS=1 /qn /norestart TARGETDIR=`"C:\Program Files (x86)\Microsoft\TeamsMeetingAddin\$version\`"" -Wait -ErrorAction Stop
- Log-Message "Teams Meeting Addin installation completed successfully."
- } catch {
- $errorMessage = "Failed to install Teams Meeting Addin: $_"
- Log-Message $errorMessage
- Write-Host $errorMessage -ForegroundColor Red
- exit 1
- }
- } else {
- $warningMessage = "Teams Meeting Addin installer not found."
- Log-Message $warningMessage
- Write-Host $warningMessage -ForegroundColor Yellow
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement