Short:
Get-ChildItem IIS:\Sites
Get-ChildItem IIS:\Sites | Get-CliXml sites.xml
returns one thing as string and another as xml. Why?
Longer:
When I run
Get-ChildItem IIS:\Sites
I get something in the line of
Name ID State Phys...
Default Web Site 1 Started C:\i...
MyTestSite 2 Started C:\i...
but when I pipe it to Export-CliXml like so:
Get-ChildItem IIS:\Sites | Get-CliXml sites.xml
I get nothing with "Default Web Site" or "MyTestSite" in it. => The string and xml don't have anything in common.
When I do the same with Get-Process
Get-Process | Export-CliXml processes.xml
I can find my processes in the output file. => What is in the string can be found in the xml.
Why does Get-Process output about the same as text and xml
while Get-ChildItems IIS:\\Sites one text and something else as xml?
What is it I have misunderstood?
I guess a problem might be that I get an exception from Get-ChildItem iis:\\sites but output is still generated. The xml output seems ok too.
Update:
When I do
Get-ChildItem IIS:\Sites | select Name,ID,State,PhysicalPath | Get-CliXml sites.xml
I get the values I am looking for.
When I add Bindings
Get-ChildItem IIS:\Sites | select Name,ID,State,PhysicalPath,Bindings | Get-CliXml sites.xml
only 2 sites are iterated and I get an error message. The xml is fine anyway. (some well constructed try-catch in the code i believe)
Can someone confirm or deny that
get-childitem iis:\sites
gives back an object with lots of objects (not strings and integers)
and when this is piped to
export-clixml
the code will do a ToString on every property and return type names for them.
If the above is the case (which it probably is) the solution is to
Get-ChildItem IIS:\Sites | select Name,ID,State,PhysicalPath | Get-CliXml sites.xml
but not for complex properties like Binding.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.