使用Format-Table命令无法在注册表中看到完整的密钥名称

时间:2014-03-09 06:37:05

标签: powershell windows-7 registry

我试图在注册表中看到完整的密钥名称,因为我想稍后将它们复制到文本文件中,但我看不到全名。 所以首先我进入我需要的注册表配置单元:
cd HKLM:
cd SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ ModuleUsage

现在我跑: Get-ChildItem |格式表名称 但这是我收到的: enter image description here

我试图将它复制到文本文件中,因为GUI可能没有显示它,但它没有帮助。 所以我尝试用'Format-List'替换'Format-Table',它显示了全名: enter image description here

但是现在我需要运行一些函数来删除'Name:',这应该不是问题,但我想知道是否可以用'Format-Table'向我显示全名

由于

2 个答案:

答案 0 :(得分:2)

Format- *命令用于格式化您的观看乐趣。它们并不意味着沿着管道传递可用的对象 - 如果你尝试对Format- *命令的结果做任何事情,除了将它发送到Out- String或Out-File之类的Out- *命令之外,你会得到胡言乱语

使用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

通常,您应该避免使用Format- *命令,除非您有特定的目标。例如,为了清楚起见,将它们与Write-Verbose或ShouldProcess消息一起使用。请记住,一旦使用Format - *。

,您就失去了使用数据作为对象的能力

干杯!

答案 1 :(得分:1)

您可以使用Format-Table的-Wrap开关。它指定超出列宽的文本在下一行上移动。默认情况下,超出列宽的文本将被截断。

Get-ChildItem | Format-Table Name -Wrap
相关问题