Powershell使用get-website的网站列表?

Mik*_*e J 14 iis powershell

我在使用基本的PowerShell命令时遇到了一些麻烦.

如果我运行get-website(在启用webadministration snappin之后)并运行"%SystemRoot%\ system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -ImportSystemModules",我会在IIS上看到10个左右的网站列表Server 2008 Standard上的7.0服务器(SP2,而不是R2).通过列出这些项目,它按预期工作:

  • 名称
  • ID
  • 物理路径
  • 绑定

但当我这样做时:

获取网站| export-csv C:\ my_list.csv

我使用"Microsoft.IIs.PowerShell.Framework.ConfigurationElement"而不是实际值获得更多项目.

当它导出为CSV时,它也会在没有事先(当输出在shell中时)时为绑定说"Microsoft.IIs.PowerShell.Framework.ConfigurationElement".

那里有点......

有没有办法我可以修改单行,所以我可以有一个没有"Microsoft.IIs.PowerShell.Framework.ConfigurationElement"的所有细节的网站列表?

CB.*_*CB. 26

尝试

get-website | select name,id,state, physicalpath,
@{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ';' }} |
Export-Csv -NoTypeInformation -Path C:\my_list.csv
Run Code Online (Sandbox Code Playgroud)

- 评论后编辑:

get-website | select name,id,state,physicalpath, 
@{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ';' }} ,
@{n="LogFile";e={ $_.logfile | select -expa directory}}, 
@{n="attributes"; e={($_.attributes | % { $_.name + "=" + $_.value }) -join ';' }} |
Export-Csv -NoTypeInformation -Path C:\my_list.csv
Run Code Online (Sandbox Code Playgroud)