Given a uninstallString of "C:\ProgramData\Package Cache\{56e11d69-7cc9-40a5-a4f9-8f6190c4d84d}\VC_redist.x86.exe" /uninstall
I can successfully extract the quoted text with ([Regex]::Match($uninstallString, '^\".*\"').Value)
. however, if I test to see if the string has the required /uninstall bit, then try to extract the quoted bit, like this...
if ([Regex]::Match($uninstallString, '^\".*\" +/uninstall').Succes) {
([Regex]::Match($uninstallString, '^\".*\"').Value)
}
Instead of the value being the full string, it's only returning "C:\ProgramData\Package
. Now, My understanding is that . is everything but a line break, so it should be OK with the space. But, if I replace the space with an underscore in the string it works as expected, so it's definitely the space causing the issue.
Also, I am confused why it works outside of the If, but not inside. I was under the impression that using [Regex]::Match() creates individual objects with each use, that wouldn't interact with each other, but here it seems they are.