[ad_1]
I’m trying to knock out a simple enough (I thought) script to clean up older versions of Zoom that were deployed via browser but leaving fully installed versions alone.
Put together the following:
$UserDir = "C:\Users"
$TargetFolder = "AppData\Roaming\Zoom\bin"
Get-ChildItem $UserDir -Directory -Exclude Default*,Public | foreach {
$joined_path = Join-Path -Path $_,FullName -ChildPath $TargetFolder
if (Test-Path $joined_path) {
remove-item "$joined_path\" -Force
}
}
And it ‘kind of’ works, I’m getting the following error:
remove-item : Cannot find path 'C:\Users\Admin\AppData\Roaming\Zoom\bin FullName\AppData\Roaming\Zoom\bin\'
because it does not exist.
It’s apparent that I’m not understanding the join-path command quite right, and it’s duplicating the path it’s searching for.
The idea here is to delete the target directory (\AppData\Roaming\Zoom\Bin) from all profiles – ironically perhaps the error messages show that it is searching through multiple profiles, but it’s tagging on the path part twice and I’m confused as to why.
[ad_2]