Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - XML processing my web.config file in PowerShell

Reply
 
Old 01-04-2008   #1 (permalink)
Marc Scheuner


 
 

XML processing my web.config file in PowerShell

Folks,

I'm trying to get the hang of dealing with my web.config files for
ASP.NET from PowerShell.

Now I can easily load a web.config and all:

PS> [xml]$x = ${web.config}

PS> $x

xml configuration
--- -------------
configuration

PS> $x.configuration

xmlns : http://schemas.microsoft.com/.NetConfiguration/v2.0
configSections : configSections
appSettings : appSettings
system.web : system.web
system.webServer : system.webServer

but the tricky question is: how can I access the "system.web" sections
where the real meat of the config is??

I can easily get into $x.configuration.configSections, or
$x.configuration.appSettings, but no luck with
$x.configuration.system.web........ what's the "magic" trick to unlock
that??? :-)

Thanks!
Marc

My System SpecsSystem Spec
Old 01-04-2008   #2 (permalink)
Shay Levi


 
 

Re: XML processing my web.config file in PowerShell



Because system.web has a dot, the "web" is treated as a property and there
is no "web" element.
Try to wrap it with quotation marks and append the child element manually.

$x.configuration."system.web".webServices

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> Folks,
>
> I'm trying to get the hang of dealing with my web.config files for
> ASP.NET from PowerShell.
>
> Now I can easily load a web.config and all:
>
PS>> [xml]$x = ${web.config}
PS>>
PS>> $x
PS>>
Quote:

> xml configuration
> --- -------------
> configuration
PS>> $x.configuration
PS>>
Quote:

> xmlns : http://schemas.microsoft.com/.NetConfiguration/v2.0
> configSections : configSections
> appSettings : appSettings
> system.web : system.web
> system.webServer : system.webServer
> but the tricky question is: how can I access the "system.web" sections
> where the real meat of the config is??
>
> I can easily get into $x.configuration.configSections, or
> $x.configuration.appSettings, but no luck with
> $x.configuration.system.web........ what's the "magic" trick to unlock
> that??? :-)
>
> Thanks!
> Marc

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Powershell.exe.config PowerShell
Processing xml log files in PowerShell PowerShell
Powershell and cmdlet config files PowerShell
PowerShell integrated with 'DataBatcher' batch-processing .NET 2.0 PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46