在不使用 Foreach 的情况下从 PowerShell 哈希表中选择项目 [英] Select item from PowerShell hashtable without using Foreach

查看:48
本文介绍了在不使用 Foreach 的情况下从 PowerShell 哈希表中选择项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 PSObjects 列表,每个列表包含一个 Hashtable.目前我可以这样解决:

I have this list of PSObjects, each of which contains a Hashtable. Currently I can get it out like this:

foreach ($myListOfItems 中的 $item) { $item.Metadata["Title"] }

但是,我想知道我是否可以通过管道和 Select 以某种方式做到这一点.这可能吗?例如:

However, I am wondering if I can do it somehow with piping and Select. Is this possible? For example:

<代码>$myListOfItems |选择 $_.Metadata["Title"]...只输出一大堆空行:(

$myListOfItems | Select $_.Metadata["Title"] ...which only outputs a whole bunch of blank lines :(

有什么想法吗?非常感谢!

Any ideas? Thanks so much in advance!

推荐答案

怎么样

$myListOfItems | select @{ Label="Title";Expression={$_.Metadata["Title"]}}    

这篇关于在不使用 Foreach 的情况下从 PowerShell 哈希表中选择项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆