1

I have this part of code -

$result = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | 
    Select-Object DisplayName, Publisher, InstallDate, UnistallString | 
    Where-Object InstallDate -GT 20180201 | 
    Where-Object UnistallDate -NotMatch " " | 
    Sort-Object -Property InstallDate -Descending | 
    Format-Table –AutoSize
$result

With the result of this command I get an array of objects, but if I try to access in it I get no result.

Example: $result.UnisistallString. How can I access in it to get only the attributes of that parameter? Because with that then I need to print on video the name of the program and the unistall path.

1
  • | Format-Table –AutoSize - remove this part. Commented Mar 7, 2018 at 11:51

1 Answer 1

1

You should not use the Format-Table cmdlet if you need to access the data in your code later. Also you have a typo in your example and the select statement. This should work:

$result = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | 
    Select-Object DisplayName, Publisher, InstallDate, UninstallString | 
    Where-Object InstallDate -GT 20180201 |  
    Sort-Object -Property InstallDate -Descending

Now Access it using:

$result.UninstallString
Sign up to request clarification or add additional context in comments.

11 Comments

Still cant access to that, if i run the script i get 0 result on display
I'll try to explain, after the get-itemproperty i should access to the array to print only the name of the program and his unistall path. But if i cant access to the array i cant print that
I also tried to use the get-wmiobject for the same purpose, but after the query i cant access to any property of the result
As I wrote, please try my code again, I had to fix another typo that you made in the select statement.
Where-Object UnistallDate -NotMatch " " is not doing any good here since there is no UnistallDate property even if it was spelled correctly....
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.