I should start this by saying, I enjoy solving problems with PowerShell, but my PowerShell skills are severely lacking. So if you do reply, please be as basic as you can about it :D
Microsoft Teams installs in AppData
. Multiple users sign into various PCs, leave behind old versions of Teams which we now need to clean up without affecting currently signed in user and newer versions of Teams.
Because of this, I have been going down the route of VersionInfo.FileVerson
to resolve this. The various methods I have tried, I can get so far with and then no further. I can list the FullName
and FileVersion
but I don't know how to omit the newer versions we want to leave alone.
I found this method which seems really clean compared to what I had written, and it gets me to the same stage as my script;
cd G:\test\users\ Get-ChildItem -Filter wire*.exe -Recurse |
ForEach-Object {
try {
$_ | Add-Member NoteProperty FileVersion ($_.VersionInfo.FileVersion)
$_ | Add-Member NoteProperty AssemblyVersion (
[Reflection.AssemblyName]::GetAssemblyName($_.FullName).Version
)
} catch {}
$_
} | Select-Object FullName,FileVersion -outvariable info
From her, my idea is something along the lines of $info.where{$_.FileVersion -lt '3.4.4.0'}
.
In testing this sort of thing with, for example, running services I can see how easy it is. So I am not sure how I do this, if someone could point me in the right direction for this I would be so grateful.