![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | config file problems I'm trying to use a section from a web.config file that I use to troubleshoot WebServices within asp.net applications. However, it doesn't seem to load at all. I've named it 'powershell.exe.config' and put it in the same folder as powershell.exe Can anyone spot why this isn't working? Thanks, n ---------------------- <?xml version="1.0"?> <configuration> <system.diagnostics> <trace autoflush="true"/> <sources> <source name="System.Net" maxdatasize="9000"> <listeners> <add name="TraceFile"/> </listeners> </source> <source name="System.Net.Sockets" maxdatasize="9000"> <listeners> <add name="TraceFile"/> </listeners> </source> </sources> <sharedListeners> <add name="TraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\logs\pmws.log"/> </sharedListeners> <switches> <add name="System.Net" value="Verbose"/> <add name="System.Net.Sockets" value="Verbose"/> </switches> </system.diagnostics> </configuration> |
My System Specs![]() |
| | #2 (permalink) |
| | Re: config file problems Hello Neil, I guess this is where you end up: $psxml.configuration.system.diagnostics In that case wrap system.diagnostics in quotes,the dot inside the tag name is the trouble maker, making PS to think it is a child element (property) of "system": $psxml.configuration."system.diagnostics" trace sources sharedListeners switches ----- ------- --------------- -------- trace sources sharedListeners switches --- Shay Levy Windows PowerShell http://blogs.microsoft.co.il/blogs/ScriptFanatic NC> I'm trying to use a section from a web.config file that I use to NC> troubleshoot WebServices within asp.net applications. However, it NC> doesn't NC> seem to load at all. NC> I've named it 'powershell.exe.config' and put it in the same folder NC> as NC> powershell.exe NC> Can anyone spot why this isn't working? NC> NC> Thanks, NC> n NC> ---------------------- NC> <?xml version="1.0"?> NC> <configuration> NC> <system.diagnostics> NC> <trace autoflush="true"/> NC> <sources> NC> <source name="System.Net" maxdatasize="9000"> NC> <listeners> NC> <add name="TraceFile"/> NC> </listeners> NC> </source> NC> <source name="System.Net.Sockets" maxdatasize="9000"> NC> <listeners> NC> <add name="TraceFile"/> NC> </listeners> NC> </source> NC> </sources> NC> <sharedListeners> NC> <add name="TraceFile" NC> type="System.Diagnostics.TextWriterTraceListener" NC> initializeData="c:\logs\pmws.log"/> NC> </sharedListeners> NC> <switches> NC> <add name="System.Net" value="Verbose"/> NC> <add name="System.Net.Sockets" value="Verbose"/> NC> </switches> NC> </system.diagnostics> NC> </configuration> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: config file problems Hi Shay, Thanks for the insight but I wonder if you might expand on it. I tried using quotes but that broke the configuration and psh refused to open. I suspect I have misunderstood what you mean... <configuration> <"system.diagnostics"> Cheers, n "Shay Levy [MVP]" <no@xxxxxx> wrote in message news:89228ed23b1908cac53f4bc10a98@xxxxxx Quote: > Hello Neil, > > > I guess this is where you end up: > > $psxml.configuration.system.diagnostics > > > > In that case wrap system.diagnostics in quotes,the dot inside the tag name > is the trouble maker, making PS to think it is a child element (property) > of "system": > > $psxml.configuration."system.diagnostics" > > trace sources sharedListeners switches > ----- ------- --------------- -------- > trace sources sharedListeners switches > > > --- > Shay Levy > Windows PowerShell > http://blogs.microsoft.co.il/blogs/ScriptFanatic > > NC> I'm trying to use a section from a web.config file that I use to > NC> troubleshoot WebServices within asp.net applications. However, it > NC> doesn't > NC> seem to load at all. > NC> I've named it 'powershell.exe.config' and put it in the same folder > NC> as > NC> powershell.exe > NC> Can anyone spot why this isn't working? > NC> NC> Thanks, > NC> n > NC> ---------------------- > NC> <?xml version="1.0"?> > NC> <configuration> > NC> <system.diagnostics> > NC> <trace autoflush="true"/> > NC> <sources> > NC> <source name="System.Net" maxdatasize="9000"> > NC> <listeners> > NC> <add name="TraceFile"/> > NC> </listeners> > NC> </source> > NC> <source name="System.Net.Sockets" maxdatasize="9000"> > NC> <listeners> > NC> <add name="TraceFile"/> > NC> </listeners> > NC> </source> > NC> </sources> > NC> <sharedListeners> > NC> <add name="TraceFile" > NC> type="System.Diagnostics.TextWriterTraceListener" > NC> initializeData="c:\logs\pmws.log"/> > NC> </sharedListeners> > NC> <switches> > NC> <add name="System.Net" value="Verbose"/> > NC> <add name="System.Net.Sockets" value="Verbose"/> > NC> </switches> > NC> </system.diagnostics> > NC> </configuration> > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: config file problems Hi Neil, You need to enclose the node name in your code not in the xml file: PS > $xml = [xml] (get-content config.xml) PS > $xml xml configuration --- ------------- version="1.0" configuration # navigate to the configuration node PS > $xml.configuration system.diagnostics ------------------ system.diagnostics # now if you try to navigate into the system.diagnostics node then you'll get nothing # becuase there is no such node, the dot inside the node tag name makes PS think it is a child element (property) of the "system" node. # to workaround it enclose the node name with quotes PS > $xml.configuration.system.diagnostics # no output PS > $xml.configuration."system.diagnostics" trace sources sharedListeners switches ----- ------- --------------- -------- trace sources sharedListeners switches Now you can navigate down to the child nodes: PS > $xml.configuration."system.diagnostics".trace autoflush --------- true --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic NC> Hi Shay, NC> NC> Thanks for the insight but I wonder if you might expand on it. I NC> tried using quotes but that broke the configuration and psh refused NC> to open. I suspect I have misunderstood what you mean... NC> NC> <configuration> NC> <"system.diagnostics"> NC> Cheers, NC> n NC> "Shay Levy [MVP]" <no@xxxxxx> wrote in message NC> news:89228ed23b1908cac53f4bc10a98@xxxxxx NC> Quote: Quote: >> Hello Neil, >> >> I guess this is where you end up: >> >> $psxml.configuration.system.diagnostics >> >> In that case wrap system.diagnostics in quotes,the dot inside the tag >> name is the trouble maker, making PS to think it is a child element >> (property) of "system": >> >> $psxml.configuration."system.diagnostics" >> >> trace sources sharedListeners switches >> ----- ------- --------------- -------- >> trace sources sharedListeners switches >> --- >> Shay Levy >> Windows PowerShell >> http://blogs.microsoft.co.il/blogs/ScriptFanatic >> NC> I'm trying to use a section from a web.config file that I use to >> NC> troubleshoot WebServices within asp.net applications. However, it >> NC> doesn't >> NC> seem to load at all. >> NC> I've named it 'powershell.exe.config' and put it in the same >> folder >> NC> as >> NC> powershell.exe >> NC> Can anyone spot why this isn't working? >> NC> NC> Thanks, >> NC> n >> NC> ---------------------- >> NC> <?xml version="1.0"?> >> NC> <configuration> >> NC> <system.diagnostics> >> NC> <trace autoflush="true"/> >> NC> <sources> >> NC> <source name="System.Net" maxdatasize="9000"> >> NC> <listeners> >> NC> <add name="TraceFile"/> >> NC> </listeners> >> NC> </source> >> NC> <source name="System.Net.Sockets" maxdatasize="9000"> >> NC> <listeners> >> NC> <add name="TraceFile"/> >> NC> </listeners> >> NC> </source> >> NC> </sources> >> NC> <sharedListeners> >> NC> <add name="TraceFile" >> NC> type="System.Diagnostics.TextWriterTraceListener" >> NC> initializeData="c:\logs\pmws.log"/> >> NC> </sharedListeners> >> NC> <switches> >> NC> <add name="System.Net" value="Verbose"/> >> NC> <add name="System.Net.Sockets" value="Verbose"/> >> NC> </switches> >> NC> </system.diagnostics> >> NC> </configuration> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: config file problems Thanks Shay that does make more sense. I can indeed navigate the xml document now. I am still slightly confiused though. If I cannot get these values loaded as part of the .NET configuration upon powershell launch, how can I use the xml document in code to get the values loaded? Your guidance is very much appreciated! N "Shay Levy [MVP]" <no@xxxxxx> wrote in message news:95d808933b2b28cac55d54200130@xxxxxx Quote: > Hi Neil, > > You need to enclose the node name in your code not in the xml file: > > > PS > $xml = [xml] (get-content config.xml) > PS > $xml > > xml configuration > --- ------------- > version="1.0" configuration > > > # navigate to the configuration node > PS > $xml.configuration > > system.diagnostics > ------------------ > system.diagnostics > > > # now if you try to navigate into the system.diagnostics node then you'll > get nothing # becuase there is no such node, the dot inside the node tag > name makes PS think it is a child element (property) of the "system" node. > # to workaround it enclose the node name with quotes > > PS > $xml.configuration.system.diagnostics > # no output > > > > PS > $xml.configuration."system.diagnostics" > trace sources sharedListeners switches > ----- ------- --------------- -------- > trace sources sharedListeners switches > > > Now you can navigate down to the child nodes: > > PS > $xml.configuration."system.diagnostics".trace > > autoflush > --------- > true > > > > > > > --- > Shay Levy > Windows PowerShell MVP > http://blogs.microsoft.co.il/blogs/ScriptFanatic > > > > NC> Hi Shay, > NC> NC> Thanks for the insight but I wonder if you might expand on it. I > NC> tried using quotes but that broke the configuration and psh refused > NC> to open. I suspect I have misunderstood what you mean... > NC> NC> <configuration> > NC> <"system.diagnostics"> > NC> Cheers, > NC> n > NC> "Shay Levy [MVP]" <no@xxxxxx> wrote in message > NC> news:89228ed23b1908cac53f4bc10a98@xxxxxx > NC> Quote: Quote: >>> Hello Neil, >>> >>> I guess this is where you end up: >>> >>> $psxml.configuration.system.diagnostics >>> >>> In that case wrap system.diagnostics in quotes,the dot inside the tag >>> name is the trouble maker, making PS to think it is a child element >>> (property) of "system": >>> >>> $psxml.configuration."system.diagnostics" >>> >>> trace sources sharedListeners switches >>> ----- ------- --------------- -------- >>> trace sources sharedListeners switches >>> --- >>> Shay Levy >>> Windows PowerShell >>> http://blogs.microsoft.co.il/blogs/ScriptFanatic >>> NC> I'm trying to use a section from a web.config file that I use to >>> NC> troubleshoot WebServices within asp.net applications. However, it >>> NC> doesn't >>> NC> seem to load at all. >>> NC> I've named it 'powershell.exe.config' and put it in the same >>> folder >>> NC> as >>> NC> powershell.exe >>> NC> Can anyone spot why this isn't working? >>> NC> NC> Thanks, >>> NC> n >>> NC> ---------------------- >>> NC> <?xml version="1.0"?> >>> NC> <configuration> >>> NC> <system.diagnostics> >>> NC> <trace autoflush="true"/> >>> NC> <sources> >>> NC> <source name="System.Net" maxdatasize="9000"> >>> NC> <listeners> >>> NC> <add name="TraceFile"/> >>> NC> </listeners> >>> NC> </source> >>> NC> <source name="System.Net.Sockets" maxdatasize="9000"> >>> NC> <listeners> >>> NC> <add name="TraceFile"/> >>> NC> </listeners> >>> NC> </source> >>> NC> </sources> >>> NC> <sharedListeners> >>> NC> <add name="TraceFile" >>> NC> type="System.Diagnostics.TextWriterTraceListener" >>> NC> initializeData="c:\logs\pmws.log"/> >>> NC> </sharedListeners> >>> NC> <switches> >>> NC> <add name="System.Net" value="Verbose"/> >>> NC> <add name="System.Net.Sockets" value="Verbose"/> >>> NC> </switches> >>> NC> </system.diagnostics> >>> NC> </configuration> > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: config file problems It will be a lot easier to answer if you specify what exactly which values you want to load and when. Can you provide a description of your mission? --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic NC> Thanks Shay that does make more sense. I can indeed navigate the xml NC> document now. NC> NC> I am still slightly confiused though. If I cannot get these values NC> loaded as part of the .NET configuration upon powershell launch, how NC> can I use the xml document in code to get the values loaded? NC> NC> Your guidance is very much appreciated! NC> NC> N NC> NC> "Shay Levy [MVP]" <no@xxxxxx> wrote in message NC> news:95d808933b2b28cac55d54200130@xxxxxx NC> Quote: Quote: >> Hi Neil, >> >> You need to enclose the node name in your code not in the xml file: >> >> PS > $xml = [xml] (get-content config.xml) >> PS > $xml >> xml configuration >> --- ------------- >> version="1.0" configuration >> # navigate to the configuration node >> PS > $xml.configuration >> system.diagnostics >> ------------------ >> system.diagnostics >> # now if you try to navigate into the system.diagnostics node then >> you'll get nothing # becuase there is no such node, the dot inside >> the node tag name makes PS think it is a child element (property) of >> the "system" node. # to workaround it enclose the node name with >> quotes >> >> PS > $xml.configuration.system.diagnostics >> # no output >> PS > $xml.configuration."system.diagnostics" >> trace sources sharedListeners switches >> ----- ------- --------------- -------- >> trace sources sharedListeners switches >> Now you can navigate down to the child nodes: >> >> PS > $xml.configuration."system.diagnostics".trace >> >> autoflush >> --------- >> true >> --- >> Shay Levy >> Windows PowerShell MVP >> http://blogs.microsoft.co.il/blogs/ScriptFanatic >> NC> Hi Shay, >> NC> NC> Thanks for the insight but I wonder if you might expand on >> it. I >> NC> tried using quotes but that broke the configuration and psh >> refused >> NC> to open. I suspect I have misunderstood what you mean... >> NC> NC> <configuration> >> NC> <"system.diagnostics"> >> NC> Cheers, >> NC> n >> NC> "Shay Levy [MVP]" <no@xxxxxx> wrote in message >> NC> news:89228ed23b1908cac53f4bc10a98@xxxxxx >> NC> Quote: >>>> Hello Neil, >>>> >>>> I guess this is where you end up: >>>> >>>> $psxml.configuration.system.diagnostics >>>> >>>> In that case wrap system.diagnostics in quotes,the dot inside the >>>> tag name is the trouble maker, making PS to think it is a child >>>> element (property) of "system": >>>> >>>> $psxml.configuration."system.diagnostics" >>>> >>>> trace sources sharedListeners switches >>>> ----- ------- --------------- -------- >>>> trace sources sharedListeners switches >>>> --- >>>> Shay Levy >>>> Windows PowerShell >>>> http://blogs.microsoft.co.il/blogs/ScriptFanatic >>>> NC> I'm trying to use a section from a web.config file that I use >>>> to >>>> NC> troubleshoot WebServices within asp.net applications. However, >>>> it >>>> NC> doesn't >>>> NC> seem to load at all. >>>> NC> I've named it 'powershell.exe.config' and put it in the same >>>> folder >>>> NC> as >>>> NC> powershell.exe >>>> NC> Can anyone spot why this isn't working? >>>> NC> NC> Thanks, >>>> NC> n >>>> NC> ---------------------- >>>> NC> <?xml version="1.0"?> >>>> NC> <configuration> >>>> NC> <system.diagnostics> >>>> NC> <trace autoflush="true"/> >>>> NC> <sources> >>>> NC> <source name="System.Net" maxdatasize="9000"> >>>> NC> <listeners> >>>> NC> <add name="TraceFile"/> >>>> NC> </listeners> >>>> NC> </source> >>>> NC> <source name="System.Net.Sockets" maxdatasize="9000"> >>>> NC> <listeners> >>>> NC> <add name="TraceFile"/> >>>> NC> </listeners> >>>> NC> </source> >>>> NC> </sources> >>>> NC> <sharedListeners> >>>> NC> <add name="TraceFile" >>>> NC> type="System.Diagnostics.TextWriterTraceListener" >>>> NC> initializeData="c:\logs\pmws.log"/> >>>> NC> </sharedListeners> >>>> NC> <switches> >>>> NC> <add name="System.Net" value="Verbose"/> >>>> NC> <add name="System.Net.Sockets" value="Verbose"/> >>>> NC> </switches> >>>> NC> </system.diagnostics> >>>> NC> </configuration> |
My System Specs![]() |
| | #7 (permalink) |
| | Re: config file problems I want to use System.Net tracing to show the data that is being sent back and forth over the network during a powershell session. This is particularly useful (to me) for troubleshooting SOAP applications (although it is certainly not limited to that). The examples I've seen use app.config or web.config in order to get things working. I am led to believe that powershell, as a .NET application, can take advantage of these configuration files. I have an asp.net application that uses this feature via a web.config file. the powershell.exe.config file I am trying to get working has been taken directly from my working web.confilg file - that is everything between the <system.diagnostic> tags. However, if I try to set properties manually within a session, I fall into trouble. I can access [system.diagnostics.trace]::autoflush and set it to true. However, I cannot access [system.diagnostics.sources] - this does not exist. [system.diagnostics.tracesource] does exist (and seems a logical choice) but I cannot translate the configuration items needed into viable settings within this namespace. Here are a few links to give you a more erudite explanation of what I am trying to do. http://blogs.msdn.com/dgorti/archive...18/471003.aspx http://support.microsoft.com/kb/947285 http://msdn.microsoft.com/en-us/magazine/cc300790.aspx Cheers! n "Shay Levy [MVP]" <no@xxxxxx> wrote in message news:95d808933b2d88cac5649b154580@xxxxxx Quote: > It will be a lot easier to answer if you specify what exactly which values > you want to load and when. > Can you provide a description of your mission? > > --- > Shay Levy > Windows PowerShell MVP > http://blogs.microsoft.co.il/blogs/ScriptFanatic > > > > NC> Thanks Shay that does make more sense. I can indeed navigate the xml > NC> document now. > NC> NC> I am still slightly confiused though. If I cannot get these values > NC> loaded as part of the .NET configuration upon powershell launch, how > NC> can I use the xml document in code to get the values loaded? > NC> NC> Your guidance is very much appreciated! > NC> NC> N > NC> NC> "Shay Levy [MVP]" <no@xxxxxx> wrote in message > NC> news:95d808933b2b28cac55d54200130@xxxxxx > NC> Quote: Quote: >>> Hi Neil, >>> >>> You need to enclose the node name in your code not in the xml file: >>> >>> PS > $xml = [xml] (get-content config.xml) >>> PS > $xml >>> xml configuration >>> --- ------------- >>> version="1.0" configuration >>> # navigate to the configuration node >>> PS > $xml.configuration >>> system.diagnostics >>> ------------------ >>> system.diagnostics >>> # now if you try to navigate into the system.diagnostics node then >>> you'll get nothing # becuase there is no such node, the dot inside >>> the node tag name makes PS think it is a child element (property) of >>> the "system" node. # to workaround it enclose the node name with >>> quotes >>> >>> PS > $xml.configuration.system.diagnostics >>> # no output >>> PS > $xml.configuration."system.diagnostics" >>> trace sources sharedListeners switches >>> ----- ------- --------------- -------- >>> trace sources sharedListeners switches >>> Now you can navigate down to the child nodes: >>> >>> PS > $xml.configuration."system.diagnostics".trace >>> >>> autoflush >>> --------- >>> true >>> --- >>> Shay Levy >>> Windows PowerShell MVP >>> http://blogs.microsoft.co.il/blogs/ScriptFanatic >>> NC> Hi Shay, >>> NC> NC> Thanks for the insight but I wonder if you might expand on >>> it. I >>> NC> tried using quotes but that broke the configuration and psh >>> refused >>> NC> to open. I suspect I have misunderstood what you mean... >>> NC> NC> <configuration> >>> NC> <"system.diagnostics"> >>> NC> Cheers, >>> NC> n >>> NC> "Shay Levy [MVP]" <no@xxxxxx> wrote in message >>> NC> news:89228ed23b1908cac53f4bc10a98@xxxxxx >>> NC> >>>>> Hello Neil, >>>>> >>>>> I guess this is where you end up: >>>>> >>>>> $psxml.configuration.system.diagnostics >>>>> >>>>> In that case wrap system.diagnostics in quotes,the dot inside the >>>>> tag name is the trouble maker, making PS to think it is a child >>>>> element (property) of "system": >>>>> >>>>> $psxml.configuration."system.diagnostics" >>>>> >>>>> trace sources sharedListeners switches >>>>> ----- ------- --------------- -------- >>>>> trace sources sharedListeners switches >>>>> --- >>>>> Shay Levy >>>>> Windows PowerShell >>>>> http://blogs.microsoft.co.il/blogs/ScriptFanatic >>>>> NC> I'm trying to use a section from a web.config file that I use >>>>> to >>>>> NC> troubleshoot WebServices within asp.net applications. However, >>>>> it >>>>> NC> doesn't >>>>> NC> seem to load at all. >>>>> NC> I've named it 'powershell.exe.config' and put it in the same >>>>> folder >>>>> NC> as >>>>> NC> powershell.exe >>>>> NC> Can anyone spot why this isn't working? >>>>> NC> NC> Thanks, >>>>> NC> n >>>>> NC> ---------------------- >>>>> NC> <?xml version="1.0"?> >>>>> NC> <configuration> >>>>> NC> <system.diagnostics> >>>>> NC> <trace autoflush="true"/> >>>>> NC> <sources> >>>>> NC> <source name="System.Net" maxdatasize="9000"> >>>>> NC> <listeners> >>>>> NC> <add name="TraceFile"/> >>>>> NC> </listeners> >>>>> NC> </source> >>>>> NC> <source name="System.Net.Sockets" maxdatasize="9000"> >>>>> NC> <listeners> >>>>> NC> <add name="TraceFile"/> >>>>> NC> </listeners> >>>>> NC> </source> >>>>> NC> </sources> >>>>> NC> <sharedListeners> >>>>> NC> <add name="TraceFile" >>>>> NC> type="System.Diagnostics.TextWriterTraceListener" >>>>> NC> initializeData="c:\logs\pmws.log"/> >>>>> NC> </sharedListeners> >>>>> NC> <switches> >>>>> NC> <add name="System.Net" value="Verbose"/> >>>>> NC> <add name="System.Net.Sockets" value="Verbose"/> >>>>> NC> </switches> >>>>> NC> </system.diagnostics> >>>>> NC> </configuration> > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| config.nt or autoexec.nt problems | Vista file management | |||
| what is the web.config file? | Vista General | |||