Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Beginner
Hi everybody.
 
Can anybody tell me how I can access metabase.xml file through powershell? I need to get details like:
AppAllowClientDebug,
anonymous User name,
AppAllowDebugging,
AspEnableParentPaths,
AspScriptErrorSenttoBrowsers and so on from the metabase.xml through powershell.
 
This XML is located at the location : C:\WINDOWS\system32\inetsrv
Any suggestions would be of great help.
Posted 15-Dec-10 21:26pm
Edited 15-Dec-10 21:30pm
JF201553.3K
v2
Comments
JF2015 at 16-Dec-10 2:30am
   
Edited to remove pre tags.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This CodeProject article can be useful: PowerShell and XML[^].
 
This is another short article: https://devcentral.f5.com/blogs/us/powershell-abcs-x-is-for-xml[^].
 
For some more detail, please see: http://www.pavleck.net/powershell-cookbook/ch10.html[^].
 
However, these are just the PowerShell-specific aspects of it. If you need more serious approach, you can use all power of .NET API. First, you need to know how to access .NET assemblies:
http://www.pavleck.net/powershell-cookbook/ch17.html#access_a_net_sdk_library[^].
 
This is how you can load the assembly, on one example:
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
 
And then you can use all power of .NET parsing and writing available in .NET BCL. Here is my short overview of what you can use:
  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
 
You can also use C# or VB.NET code in your script using Add-Type: http://www.pavleck.net/powershell-cookbook/ch17.html#define_extend_net_class[^].
 
Happy New Year!
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 290
1 OriginalGriff 275
2 Sergey Alexandrovich Kryukov 195
3 BillWoodruff 140
4 ProgramFOX 140
0 OriginalGriff 6,524
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,218
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100