Question

I am trying to see full key names in registry because I want to copy them to a text file later but I can't see the full name. So first I enter to the registry hive I need:
cd HKLM:
cd SOFTWARE\Microsoft\Windows\CurrentVersion\ModuleUsage

And now I run: Get-ChildItem | format-table name But this is what I received: enter image description here

I tried to copy it to text file thought maybe it doesn't show it full because of the GUI but it didn't help. So I tried to replace 'Format-Table' with 'Format-List' and it show me the full name: enter image description here

But now I need to run some functions to cut the 'Name : ' off which shouldn't be a problem but I wonder if it possible to show me the full name with 'Format-Table'

Thanks

Was it helpful?

Solution

Format-* commands are built to format things for your viewing pleasure. They are not meant to pass usable objects along the pipeline - if you try to do anything with the results of a Format-* command, apart from sending it to Out-* commands like Out-String or Out-File, you will get gibberish.

Use Select-Object.

#View an array of strings (from name property)
Get-ChildItem | Select-Object -ExpandProperty name

#Write these strings to a file
Get-ChildItem | Select-Object -ExpandProperty name | Set-Content C:\temp\test.txt

In general, you should avoid the Format-* commands unless you have a specific goal in mind. For example, using them with Write-Verbose or with ShouldProcess messages for clarity. Just keep in mind you lose any ability to work with the data as objects once you use Format-*.

Cheers!

OTHER TIPS

You can use -Wrap switch of Format-Table. It specifies that text that exceeds the column width was moved on the next line. By default, text that exceeds the column width is truncated.

Get-ChildItem | Format-Table Name -Wrap
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top