Filter out blanks

by Lery at 2013-04-03 09:22:17

Hello everyone and thank you very much for taking the time to read my post. Here is the code I’m currently using.

Get-ChildItem -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |

Get-ItemProperty |

Select-Object -Property DisplayName


It works great. However, when it runs it has plenty of blank spaces in the output. Is there a way to "filter" out these blank spaces so everything is nicely together in its own row?

Here is what the output looks like
[attachment=0]Untitled.png[/attachment]
by mjolinor at 2013-04-03 09:42:15
One way:

Get-ChildItem -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |

Get-ItemProperty |

Select-Object -Property DisplayName | where {$.DisplayName}
by Lery at 2013-04-03 10:16:35
[quote="mjolinor"]One way:

Get-ChildItem -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |

Get-ItemProperty |

Select-Object -Property DisplayName | where {$
.DisplayName}[/quote]

Very good thank you. If I can ask a follow-up question? There is an InstallDate entry in the key that I can get. My code now becomes this:

Get-ChildItem -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Select-Object -Property DisplayName, installdate. | where {$.DisplayName}

It works, but the installdate is returned in the following format: 20121108

Is there a way to convert that to say: 11-08-2012?
by ArtB0514 at 2013-04-03 10:57:01
Not very pretty, but this should work:

Get-ChildItem -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where {$
.DisplayName} | Select-Object DisplayName, @{Name='Installed';Expression={"$($.installdate.Substring(4,2))-$($.installdate.Substring(6,2))-$($.installdate.Substring(0,4))"}}

Note that I moved the Where clause to before the Select clause because that will reduce the number of objects that Select will have to process.
by Lery at 2013-04-03 12:10:29
[quote="ArtB0514"]Not very pretty, but this should work:

Get-ChildItem -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where {$
.DisplayName} | Select-Object DisplayName, @{Name='Installed';Expression={"$($.installdate.Substring(4,2))-$($.installdate.Substring(6,2))-$($_.installdate.Substring(0,4))"}}

Note that I moved the Where clause to before the Select clause because that will reduce the number of objects that Select will have to process.[/quote]

Thank you, this worked perfectly.