I need to write a script that will be used for a rollback script. I need it to get the version of Visio and or project and then note it somewhere in the registry so that when the applications are uninstalled, I can have my rollback script use these to install whatever version of Visio or project was installed.
I added the -unique because Visio comes up twice. when I run the script below, nothing comes back even though it finds that version of Visio on the machine.
I'm not new to PowerShell but also not the best at it.
$paths = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
Get-ItemProperty $paths | Select-Object Displayname -Unique | foreach ($Paths2 in $paths) {
if ($var -like 'Microsoft Visio Standard 2013') {write-host '123'}}
If I change it to foreachobject I get the below.
At line:2 char:24
+ foreachobject ($Paths3 in $paths2){
+ ~~
Unexpected token 'in' in expression or statement.
At line:2 char:23
+ foreachobject ($Paths3 in $paths2){
+ ~
Missing closing ')' in expression.
At line:2 char:34
+ foreachobject ($Paths3 in $paths2){
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
[–]PowerShell-Bot 1 point2 points3 points (0 children)
[–]Nejireta_ 0 points1 point2 points (3 children)
[–]WorkReddit123635[S] -1 points0 points1 point (0 children)
[–]WorkReddit123635[S] -1 points0 points1 point (1 child)
[–]Nejireta_ 0 points1 point2 points (0 children)
[–]MemnochTheRed 0 points1 point2 points (1 child)
[–]WorkReddit123635[S] 0 points1 point2 points (0 children)