在 Powershell 中选择一个 NoteProperty
Selecting a NoteProperty in Powershell
Get-Website
returns 当前安装的列表 Websites
及其 Bindings
。
然而,
Get-Website | select Bindings
Returns 以下:
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?
已编辑:
如果我输入:
Get-Website | select -ExpandProperty bindings | select collection
我得到了专栏。
但话又说回来,我还想获得其他属性,如名称和物理路径。我该怎么做?
这应该适合您
Get-website | select Name,PhysicalPath, @{L="Bindings";E={$_.Bindings.Collection -join ";"}}
使用 calculated expression 我们使用分号分解绑定和 -join
数组元素以允许导出。这些数据应该可以通过 Export-CSV
轻松导出
Bindings
是一个对象,而不仅仅是一个字符串集合。有些有 ToString()
内置方法可以为您解决这个问题,但似乎这个方法没有,所以我们需要手动完成。
Get-Website
returns 当前安装的列表 Websites
及其 Bindings
。
然而,
Get-Website | select Bindings
Returns 以下:
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?
已编辑:
如果我输入:
Get-Website | select -ExpandProperty bindings | select collection
我得到了专栏。 但话又说回来,我还想获得其他属性,如名称和物理路径。我该怎么做?
这应该适合您
Get-website | select Name,PhysicalPath, @{L="Bindings";E={$_.Bindings.Collection -join ";"}}
使用 calculated expression 我们使用分号分解绑定和 -join
数组元素以允许导出。这些数据应该可以通过 Export-CSV
Bindings
是一个对象,而不仅仅是一个字符串集合。有些有 ToString()
内置方法可以为您解决这个问题,但似乎这个方法没有,所以我们需要手动完成。