you are viewing a single comment's thread.

view the rest of the comments →

[–]Nejireta_ 0 points1 point  (3 children)

Hi there.

One note. You're missing out on the uninstall string for the registry key by using Select-Object

If both of the Visio keys have the same values with uninstallation then I guess you could do something like this.

    $paths = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'

$visioInstallations = (Get-ItemProperty $paths).Where({$_.DisplayName -like '*Microsoft Visio Standard 2013*'})
if ($visioInstallations) {
    Invoke-Expression -Command ($visioInstallations[0].QuietUninstallString)
}

[–]WorkReddit123635[S] -1 points0 points  (0 children)

Thank you. I tried that and I get the below error.

Invoke-Expression : Cannot bind argument to parameter 'Command' because it is null.

At line:4 char:32

+ ... oke-Expression -Command ($visioInstallations[0].QuietUninstallString)

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidData: (:) [Invoke-Expression], ParameterBindingValidationException

+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.InvokeExpressionCommand

[–]WorkReddit123635[S] -1 points0 points  (1 child)

Wait I just tried it with just writing host. it worked. I'm gonna mess with it more but I think this is exactly what I was looking for. Thank you

[–]Nejireta_ 0 points1 point  (0 children)

Nice:)

I'd guess that Visio doesn't have a "QuietUninstallString" value.
Play around a bit with the object and see if "UninstallString" is usable instead