Wrecking my logic circuits as I can't comprehend Powershell with some .NET thrown together for this compare file array results. From the array results, script is then to compare each results file version against a set version and then to delete the file if is below/not equal to the set version. I tried to use sample Comparing file versions in Powershell but it I cannot find the output issue as to why the behavior works on a Windows Server 2019 vs a Windows 10 Enterprise. Deleting old profile Teams.exe data from the MS Teams Machine Wide crap. Your assistance will be most appreciated!
My script deploys through MS Endpoint/SCCM
$TeamsPath = 'C:\Users*\AppData\Local\Microsoft\Teams\current\Teams.exe'
$FileVersion = @(Get-ChildItem -Path $TeamsPath -Recurse -Force)
foreach ($TeamsPath in $FileVersion){
$ProductVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($TeamsPath).ProductVersion
$TargetVersion = [System.Version]::Parse("1.3.0.13000")
if ($ProductVersion -le $TargetVersion){
Remove-Item -Path $TeamsPath.Directory -Force -Recurse
}
}