I'm having some troubles with a basic powershell command.
If i run get-website (after enabling the webadministration snappin) and running "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -ImportSystemModules", I see a list of the 10 or so websites on my IIS 7.0 server on Server 2008 Standard (SP2, not R2). It works as expected by listing these items:
But when I do:
get-website | export-csv C:\my_list.csv
I get many more items with "Microsoft.IIs.PowerShell.Framework.ConfigurationElement" instead of the actual value.
When it's exported to CSV it also says "Microsoft.IIs.PowerShell.Framework.ConfigurationElement" for bindings when it didn't prior (when the output was in the shell).
It's sort of halfway there...
Is there a way I can modify the one-liner so I can have a list of websites with all details without "Microsoft.IIs.PowerShell.Framework.ConfigurationElement" ?
try
get-website | select name,id,state, physicalpath,
@{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ';' }} |
Export-Csv -NoTypeInformation -Path C:\my_list.csv
-edit after comment:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With