![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Re: Formatting Inline for Export-CliXML Command Two things... First.. you dont want to use select.. use foreach-object $log | foreach-object{$_.Message -replace "'", ""} | export-clixml Second.. you can try WMI object to see if parses in XML better PS> Get-WmiObject Win32_NTLogEventLog "Glenn W." <Glenn W.@xxxxxx> wrote in message news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx Quote: > Hello, > > I am trying to export the event log to a sql database and in doing so, I > exporting the eventLog as an XML string and passing it into a stored > procedure which will parse. > > My trouble is that the messages contain apostrophes which of course SQL > doesn't like and I was curious as to how I would go about escaping them in > line as I export the data. > > Something like: > $log = get-eventlog -list > $log = $log[0].Entries > > $log | select message -replace "'", "" | export-clixml > > Of course, unfortunately that doesn't work. Does anyone have any > suggestions? Thanks in advance. |
My System Specs![]() |
| | #2 (permalink) |
| | Formatting Inline for Export-CliXML Command Hello, I am trying to export the event log to a sql database and in doing so, I exporting the eventLog as an XML string and passing it into a stored procedure which will parse. My trouble is that the messages contain apostrophes which of course SQL doesn't like and I was curious as to how I would go about escaping them in line as I export the data. Something like: $log = get-eventlog -list $log = $log[0].Entries $log | select message -replace "'", "" | export-clixml Of course, unfortunately that doesn't work. Does anyone have any suggestions? Thanks in advance. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command You may find these interesting in regards to select object http://bsonposh.com/modules/wordpress/?p=25 and http://bsonposh.com/modules/wordpress/?p=26 "Glenn W." <Glenn W.@xxxxxx> wrote in message news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx Quote: > Hello, > > I am trying to export the event log to a sql database and in doing so, I > exporting the eventLog as an XML string and passing it into a stored > procedure which will parse. > > My trouble is that the messages contain apostrophes which of course SQL > doesn't like and I was curious as to how I would go about escaping them in > line as I export the data. > > Something like: > $log = get-eventlog -list > $log = $log[0].Entries > > $log | select message -replace "'", "" | export-clixml > > Of course, unfortunately that doesn't work. Does anyone have any > suggestions? Thanks in advance. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command Thank you. Your help is much appreciated. "Brandon Shell" wrote: Quote: > You may find these interesting in regards to select object > http://bsonposh.com/modules/wordpress/?p=25 > and > http://bsonposh.com/modules/wordpress/?p=26 > > "Glenn W." <Glenn W.@xxxxxx> wrote in message > news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx Quote: > > Hello, > > > > I am trying to export the event log to a sql database and in doing so, I > > exporting the eventLog as an XML string and passing it into a stored > > procedure which will parse. > > > > My trouble is that the messages contain apostrophes which of course SQL > > doesn't like and I was curious as to how I would go about escaping them in > > line as I export the data. > > > > Something like: > > $log = get-eventlog -list > > $log = $log[0].Entries > > > > $log | select message -replace "'", "" | export-clixml > > > > Of course, unfortunately that doesn't work. Does anyone have any > > suggestions? Thanks in advance. > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command Still, you can do it with select : select @{name="message";expression={$_.message -replace "'", ""}} Shay http://scriptolog.blogspot.com Quote: > Two things... > First.. you dont want to use select.. use foreach-object > $log | foreach-object{$_.Message -replace "'", ""} | export-clixml > Second.. you can try WMI object to see if parses in XML better > PS>> Quote: > "Glenn W." <Glenn W.@xxxxxx> wrote in message > news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx > Quote: >> Hello, >> >> I am trying to export the event log to a sql database and in doing >> so, I exporting the eventLog as an XML string and passing it into a >> stored procedure which will parse. >> >> My trouble is that the messages contain apostrophes which of course >> SQL doesn't like and I was curious as to how I would go about >> escaping them in line as I export the data. >> >> Something like: >> $log = get-eventlog -list >> $log = $log[0].Entries >> $log | select message -replace "'", "" | export-clixml >> >> Of course, unfortunately that doesn't work. Does anyone have any >> suggestions? Thanks in advance. >> |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command Then you lose the rest of the object You will only get the message"Shay Levi" <no@xxxxxx> wrote in message news:8766a94477d48c9c82b986b7656@xxxxxx Quote: > Still, you can do it with select : > > select @{name="message";expression={$_.message -replace "'", ""}} > > > > Shay > http://scriptolog.blogspot.com > > > Quote: >> Two things... >> First.. you dont want to use select.. use foreach-object >> $log | foreach-object{$_.Message -replace "'", ""} | export-clixml >> Second.. you can try WMI object to see if parses in XML better >> > PS>> Quote: >> "Glenn W." <Glenn W.@xxxxxx> wrote in message >> news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx >> Quote: >>> Hello, >>> >>> I am trying to export the event log to a sql database and in doing >>> so, I exporting the eventLog as an XML string and passing it into a >>> stored procedure which will parse. >>> >>> My trouble is that the messages contain apostrophes which of course >>> SQL doesn't like and I was curious as to how I would go about >>> escaping them in line as I export the data. >>> >>> Something like: >>> $log = get-eventlog -list >>> $log = $log[0].Entries >>> $log | select message -replace "'", "" | export-clixml >>> >>> Of course, unfortunately that doesn't work. Does anyone have any >>> suggestions? Thanks in advance. >>> > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command That's the issue I was having. I'm trying to collect all the information from the event log entry, but edit the message so as to remove the characters that will "piss off" SQL such as apostrophes and what not. Unfortunately, with the WMI object I was having the same issues with being unable to edit the message in line. "Brandon Shell" wrote: Quote: > Then you lose the rest of the object You will only get the message> > "Shay Levi" <no@xxxxxx> wrote in message > news:8766a94477d48c9c82b986b7656@xxxxxx Quote: > > Still, you can do it with select : > > > > select @{name="message";expression={$_.message -replace "'", ""}} > > > > > > > > Shay > > http://scriptolog.blogspot.com > > > > > > Quote: > >> Two things... > >> First.. you dont want to use select.. use foreach-object > >> $log | foreach-object{$_.Message -replace "'", ""} | export-clixml > >> Second.. you can try WMI object to see if parses in XML better > >> > > PS>> Quote: > >> "Glenn W." <Glenn W.@xxxxxx> wrote in message > >> news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx > >> > >>> Hello, > >>> > >>> I am trying to export the event log to a sql database and in doing > >>> so, I exporting the eventLog as an XML string and passing it into a > >>> stored procedure which will parse. > >>> > >>> My trouble is that the messages contain apostrophes which of course > >>> SQL doesn't like and I was curious as to how I would go about > >>> escaping them in line as I export the data. > >>> > >>> Something like: > >>> $log = get-eventlog -list > >>> $log = $log[0].Entries > >>> $log | select message -replace "'", "" | export-clixml > >>> > >>> Of course, unfortunately that doesn't work. Does anyone have any > >>> suggestions? Thanks in advance. > >>> > > > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command But the foreach helped correct? $log | foreach-object{$_.Message -replace "'", ""} | export-clixml "Glenn W." <GlennW@xxxxxx> wrote in message news:BBC2B90C-B4C4-4F1B-BF25-93870AA7FDA6@xxxxxx Quote: > That's the issue I was having. I'm trying to collect all the information > from the event log entry, but edit the message so as to remove the > characters > that will "piss off" SQL such as apostrophes and what not. > > Unfortunately, with the WMI object I was having the same issues with being > unable to edit the message in line. > > "Brandon Shell" wrote: > Quote: >> Then you lose the rest of the object You will only get the message>> >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a94477d48c9c82b986b7656@xxxxxx Quote: >> > Still, you can do it with select : >> > >> > select @{name="message";expression={$_.message -replace "'", ""}} >> > >> > >> > >> > Shay >> > http://scriptolog.blogspot.com >> > >> > >> > >> >> Two things... >> >> First.. you dont want to use select.. use foreach-object >> >> $log | foreach-object{$_.Message -replace "'", ""} | export-clixml >> >> Second.. you can try WMI object to see if parses in XML better >> >> >> > PS>> Get-WmiObject Win32_NTLogEventLog >> > PS>> >> >> "Glenn W." <Glenn W.@xxxxxx> wrote in message >> >> news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx >> >> >> >>> Hello, >> >>> >> >>> I am trying to export the event log to a sql database and in doing >> >>> so, I exporting the eventLog as an XML string and passing it into a >> >>> stored procedure which will parse. >> >>> >> >>> My trouble is that the messages contain apostrophes which of course >> >>> SQL doesn't like and I was curious as to how I would go about >> >>> escaping them in line as I export the data. >> >>> >> >>> Something like: >> >>> $log = get-eventlog -list >> >>> $log = $log[0].Entries >> >>> $log | select message -replace "'", "" | export-clixml >> >>> >> >>> Of course, unfortunately that doesn't work. Does anyone have any >> >>> suggestions? Thanks in advance. >> >>> >> > >> > >> |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command Suggestion. Wouldn't it be great if SQL could have a column of a "Here-String" type? Shay http://scriptolog.blogspot.com Quote: > That's the issue I was having. I'm trying to collect all the > information from the event log entry, but edit the message so as to > remove the characters that will "piss off" SQL such as apostrophes and > what not. > > Unfortunately, with the WMI object I was having the same issues with > being unable to edit the message in line. > > "Brandon Shell" wrote: > Quote: >> Then you lose the rest of the object You will only get the message>> >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a94477d48c9c82b986b7656@xxxxxx >> Quote: >>> Still, you can do it with select : >>> >>> select @{name="message";expression={$_.message -replace "'", ""}} >>> >>> Shay >>> http://scriptolog.blogspot.com >>>> Two things... >>>> First.. you dont want to use select.. use foreach-object >>>> $log | foreach-object{$_.Message -replace "'", ""} | export-clixml >>>> Second.. you can try WMI object to see if parses in XML better >>> PS>> Get-WmiObject Win32_NTLogEventLog >>> PS>> >>>> "Glenn W." <Glenn W.@xxxxxx> wrote in message >>>> news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx >>>> >>>>> Hello, >>>>> >>>>> I am trying to export the event log to a sql database and in doing >>>>> so, I exporting the eventLog as an XML string and passing it into >>>>> a stored procedure which will parse. >>>>> >>>>> My trouble is that the messages contain apostrophes which of >>>>> course SQL doesn't like and I was curious as to how I would go >>>>> about escaping them in line as I export the data. >>>>> >>>>> Something like: >>>>> $log = get-eventlog -list >>>>> $log = $log[0].Entries >>>>> $log | select message -replace "'", "" | export-clixml >>>>> Of course, unfortunately that doesn't work. Does anyone have any >>>>> suggestions? Thanks in advance. >>>>> |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Formatting Inline for Export-CliXML Command Maybe a different approach $log | export-clixml $temp $temp -replace "'","" | out-file $file "Glenn W." <GlennW@xxxxxx> wrote in message news:681D2EF1-5D41-498A-A4B5-7604CEB0F4F2@xxxxxx Quote: > The foreach did help, yes, but I had brain farts with applying that to > other > columns. > > I attempted a: > > $log | foreach {$_.eventId $_.message -replace "'", ""} | export-clixml > > and understandably I got an error trying to do that because it doesn't > know > what to do with those two columns. Sorry for being slow. It's been one > of > those days today. > > "Brandon Shell" wrote: > Quote: >> But the foreach helped correct? >> >> $log | foreach-object{$_.Message -replace "'", ""} | export-clixml >> >> "Glenn W." <GlennW@xxxxxx> wrote in message >> news:BBC2B90C-B4C4-4F1B-BF25-93870AA7FDA6@xxxxxx Quote: >> > That's the issue I was having. I'm trying to collect all the >> > information >> > from the event log entry, but edit the message so as to remove the >> > characters >> > that will "piss off" SQL such as apostrophes and what not. >> > >> > Unfortunately, with the WMI object I was having the same issues with >> > being >> > unable to edit the message in line. >> > >> > "Brandon Shell" wrote: >> > >> >> Then you lose the rest of the object You will only get the message>> >> >> >> "Shay Levi" <no@xxxxxx> wrote in message >> >> news:8766a94477d48c9c82b986b7656@xxxxxx >> >> > Still, you can do it with select : >> >> > >> >> > select @{name="message";expression={$_.message -replace "'", ""}} >> >> > >> >> > >> >> > >> >> > Shay >> >> > http://scriptolog.blogspot.com >> >> > >> >> > >> >> > >> >> >> Two things... >> >> >> First.. you dont want to use select.. use foreach-object >> >> >> $log | foreach-object{$_.Message -replace "'", ""} | export-clixml >> >> >> Second.. you can try WMI object to see if parses in XML better >> >> >> >> >> > PS>> Get-WmiObject Win32_NTLogEventLog >> >> > PS>> >> >> >> "Glenn W." <Glenn W.@xxxxxx> wrote in message >> >> >> news:BEE4D31B-A4A2-4214-B70A-096F589BAEBC@xxxxxx >> >> >> >> >> >>> Hello, >> >> >>> >> >> >>> I am trying to export the event log to a sql database and in doing >> >> >>> so, I exporting the eventLog as an XML string and passing it into >> >> >>> a >> >> >>> stored procedure which will parse. >> >> >>> >> >> >>> My trouble is that the messages contain apostrophes which of >> >> >>> course >> >> >>> SQL doesn't like and I was curious as to how I would go about >> >> >>> escaping them in line as I export the data. >> >> >>> >> >> >>> Something like: >> >> >>> $log = get-eventlog -list >> >> >>> $log = $log[0].Entries >> >> >>> $log | select message -replace "'", "" | export-clixml >> >> >>> >> >> >>> Of course, unfortunately that doesn't work. Does anyone have any >> >> >>> suggestions? Thanks in advance. >> >> >>> >> >> > >> >> > >> >> >> >> >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Export-clixml producing weird xml output | PowerShell | |||
| Export/Import-CliXml oddity | PowerShell | |||
| export-clixml and compare-object question | PowerShell | |||
| Export-Clixml output is inconvenient for viewing | PowerShell | |||
| Export-CliXml/Export-Csv: Change to Export-Object? | PowerShell | |||