You may start debugging your script by checking the content of the variables during runtime. In the simplest case you just output them to the console. I’d start with $_.Path.
You did not show what Get-MSISource does or outputs. If it returns drive letters without a colon at the end you may add in your code “manually”.
Thanks for your reply. I fix this “cannot find drive” issue by putting USB stick into my computer. Now I have a different case.
Remove-Item : Cannot find path 'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\03D8475ED6E7E8A3FB6E1C0DC2D6ADBB' because it does not exist.
At C:\t.ps1:100 char:9
+ Remove-Item -Recurse -Force -UseTransaction $Key
In your initial post you had the error in line 82. I’d recommend to insert the following code line right above the line 82: (actually as the new line 82 and make the old line 82 the new line 83 )
Write-Host "Content of the variable `$_.Path: '$($_.Path)'" -ForegroundColor Magenta