Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. # Define log file path
  2. $logFilePath = "C:\TEMP\Teams.log"
  3.  
  4. # Define the path to the Teams Bootstrapper
  5. $teamsBootstrapperPath = "\\domain.net\dfs$\Admin\SoftwareRepository\SWD\Microsoft\Teams\teamsbootstrapper.exe"
  6.  
  7. # Function to log messages
  8. function Log-Message {
  9. param(
  10. [string]$Message
  11. )
  12. Add-Content -Path $logFilePath -Value "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - $Message"
  13. }
  14.  
  15. # Log starting message
  16. Log-Message "Starting Teams Bootstrapper execution..."
  17.  
  18. try {
  19. # Run Teams Bootstrapper with parameter -p and wait for completion
  20. Start-Process -FilePath $teamsBootstrapperPath -ArgumentList "-p", "-o", "\\domain.net\dfs$\Admin\SoftwareRepository\SWD\Microsoft\Teams\MSTeams-x64.msix" -Wait -ErrorAction Stop
  21. Log-Message "Teams Bootstrapper execution completed successfully."
  22. } catch {
  23. $errorMessage = "Failed to run Teams Bootstrapper: $_"
  24. Log-Message $errorMessage
  25. Write-Host $errorMessage -ForegroundColor Red
  26. exit 1
  27. }
  28.  
  29. # Define the path to the installer
  30. $installerPath = "C:\Program Files\WindowsApps\MSTeams_*\MicrosoftTeamsMeetingAddinInstaller.msi"
  31.  
  32. # Get the latest version folder
  33. $teamsFolder = Get-ChildItem -Path "C:\Program Files\WindowsApps\" -Filter "MSTeams_*" -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1
  34.  
  35. # Check if Teams folder exists
  36. if ($teamsFolder) {
  37. $teamsPath = Join-Path -Path $teamsFolder.FullName -ChildPath "MicrosoftTeamsMeetingAddinInstaller.msi"
  38.  
  39. # Get the version number
  40. try {
  41. $version = (Get-AppLockerFileInformation -Path $teamsPath | Select-Object -ExpandProperty Publisher).BinaryVersion
  42. } catch {
  43. $errorMessage = "Failed to retrieve version information: $_"
  44. Log-Message $errorMessage
  45. Write-Host $errorMessage -ForegroundColor Red
  46. exit 1
  47. }
  48.  
  49. # Define the installation command
  50. $installCommand = "msiexec.exe /i `"$teamsPath`" ALLUSERS=1 /qn /norestart TARGETDIR=`"C:\Program Files (x86)\Microsoft\TeamsMeetingAddin\$version\`""
  51.  
  52. # Execute the installation command
  53. Log-Message "Installing Teams Meeting Addin version $version..."
  54. try {
  55. Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$teamsPath`" ALLUSERS=1 /qn /norestart TARGETDIR=`"C:\Program Files (x86)\Microsoft\TeamsMeetingAddin\$version\`"" -Wait -ErrorAction Stop
  56. Log-Message "Teams Meeting Addin installation completed successfully."
  57. } catch {
  58. $errorMessage = "Failed to install Teams Meeting Addin: $_"
  59. Log-Message $errorMessage
  60. Write-Host $errorMessage -ForegroundColor Red
  61. exit 1
  62. }
  63. } else {
  64. $warningMessage = "Teams Meeting Addin installer not found."
  65. Log-Message $warningMessage
  66. Write-Host $warningMessage -ForegroundColor Yellow
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement