首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Powershell中选择NoteProperty

在Powershell中选择NoteProperty
EN

Stack Overflow用户
提问于 2015-05-03 14:43:54
回答 1查看 563关注 0票数 0

Get-Website返回当前安装的Websites及其Bindings的列表。

然而,

代码语言:javascript
复制
Get-Website | select Bindings

返回以下内容:

代码语言:javascript
复制
bindings
--------
Microsoft.IIs.PowerShell.Framework.ConfigurationElement 
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Microsoft.IIs.PowerShell.Framework.ConfigurationElement

如何才能正确地将数据导出到CSV?

编辑:

如果我输入:

代码语言:javascript
复制
Get-Website | select -ExpandProperty bindings | select collection

我很好地拿到了专栏。但是,我想再一次获得其他属性,如名称和物理路径。我该怎么做?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-03 15:27:12

这应该是对你有用的东西

代码语言:javascript
复制
Get-website | select Name,PhysicalPath, @{L="Bindings";E={$_.Bindings.Collection -join ";"}}

我们使用一个计算表达式分解绑定,并使用分号对数组元素进行-join,以允许导出它。这些数据应该可以通过Export-CSV轻松地导出。

Bindings是一个对象,而不仅仅是一个字符串集合。有些方法内置了ToString()方法,可以为您解决这一问题,但似乎并不是这样的,因此我们需要手动处理。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30015148

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档