Files

67 lines
2.4 KiB
PowerShell

<#
Author: Gabe Kerntke
Date: 12-13-2023
.Synopsis
Script to install New Teams on machines that do not already have it
.Modified
2023-12-13 (GabeK) - Original script created
2025-08-07 (GabeK) - Updated to use functions script
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory = $false)]
$App_Name = "Teams",
[Parameter(Mandatory = $false)]
$File_Name_Extension = "exe",
[Parameter(Mandatory = $false)]
$Install_Parameters = "-p",
[Parameter(Mandatory = $false)]
$EPCache_Folder = "3rd Party Patches\$App_Name",
[Parameter(Mandatory = $false)]
$File_Name = "$File_Name_Prefix.$File_Name_Extension"
)
$initialURL = "https://learn.microsoft.com/en-us/microsoftteams/new-teams-bulk-install-client"
# Download the HTML content
$html = (New-Object System.Net.WebClient).DownloadString("$initialURL")
# Split the content on ">" and "<" characters to extract the text content
$text = $html.Split([char[]]@(">", "<"), [StringSplitOptions]::RemoveEmptyEntries)
# Sort the start and end index of the page
$startIndex = $text.IndexOf("Option 1A: Download and install new Teams for a single computer")
$endIndex = $text.IndexOf("Option 1B: Download and install new Teams using an offline installer")
# Extract the rows
$rows = $text[$startIndex..$endIndex]
# Filter out only the rows containing version numbers
$A = $rows | Where-Object { $_ -match "https" }
$B = $A.split() | Select-Object -First 2 | Select-Object -Last 1
$DownloadURL = $B.Substring(5) -replace '"', ""
#Region Script Start
If ((Test-Path "C:\Temp\Script Cache") -eq $False) { New-Item -ItemType directory -Path "C:\Temp\Script Cache" }
Invoke-WebRequest -UseBasicParsing "https://scripts.gabesville.com/Gabesville/Powershell-Scripts/raw/branch/main/Functions%20Scripts/Functions.ps1" -outfile "C:\Temp\Script Cache\Functions.ps1"
. "C:\Temp\Script Cache\Functions.ps1"
#Check to see if program is installed
$Applist = Get-Software | Sort-Object -Descending
If ($Applist.DisplayName -like "*$App_Name*") {
#Get currently installed version
$Local_Version = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*" } | Select-Object -ExpandProperty DisplayVersion
Write-Host "$App_Name already installed. (Installed version: $Local_Version)"
}
Else {
Test-Probe_Online
Install-App
}
#Region Script End