Powershell outcome is incomplete while scheduling PS1 from windows task scheduler.
Hi, I have created a .PS1 to fetch event ID 213 from exchange application logs. PS1 works well while executing it from powershell console and following is the output. TimeGenerated EntryType Message ------------- --------- ------- 8/27/2012 6:53:11 AM Information MSExchangeIS (7916) SG1: The backup procedure has been successfully completed.... 8/27/2012 5:28:09 AM Information MSExchangeIS (7916) SG2: The backup procedure has been successfully completed.... The output is incomplete while scheduling the same PS1 in windows task scheduler and following is the outcome. TimeGenerated EntryType Message ------------- --------- ------- 8/27/2012 10:30:00 PM Information MSExchangeIS (6076) SG1: The backup proced... 8/27/2012 10:01:10 PM Information MSExchangeIS (6076) SG2: The backup proced... I need to know why the output is incomplete and why there is difference in executing PS1 from task scheduler? and how to correct it? Please suggest... Thanks,
August 27th, 2012 5:21pm

On Mon, 27 Aug 2012 21:14:49 +0000, Gautam Kargeti wrote: >I have created a .PS1 to fetch event ID 213 from exchange application logs. PS1 works well while executing it from powershell console and following is the output. > >TimeGenerated EntryType Message ------------- --------- ------- 8/27/2012 6:53:11 AM Information MSExchangeIS (7916) SG1: The backup procedure has been successfully completed.... 8/27/2012 5:28:09 AM Information MSExchangeIS (7916) SG2: The backup procedure has been successfully completed.... > >The output is incomplete while scheduling the same PS1 in windows task scheduler and following is the outcome. > >TimeGenerated EntryType Message > >------------- --------- ------- > >8/27/2012 10:30:00 PM Information MSExchangeIS (6076) SG1: The backup proced... > >8/27/2012 10:01:10 PM Information MSExchangeIS (6076) SG2: The backup proced... > >I need to know why the output is incomplete and why there is difference in executing PS1 from task scheduler? and how to correct it? > >Please suggest... I guess I'm missing the point. Neither of the two result in the complete text of the "Message". They're both truncated. If you want the complete text then don't use the default format. Get what you want from the event into a variable and then write that to your output. If $ev contains the event, then: $x=""|TimeGenerated,EntryType,Message $x.TimeGenerated = $ev.timegenerated $x.EntryType = $ev.eventtype $x.Message = $ev.message $list += $x # delare "$list = @()" beforehand At the end: $list|export-csv <filename> -notypeinfo --- Rich Matheisen MCSE+I, Exchange MVP --- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2012 5:42pm

On Mon, 27 Aug 2012 21:14:49 +0000, Gautam Kargeti wrote: >I have created a .PS1 to fetch event ID 213 from exchange application logs. PS1 works well while executing it from powershell console and following is the output. > >TimeGenerated EntryType Message ------------- --------- ------- 8/27/2012 6:53:11 AM Information MSExchangeIS (7916) SG1: The backup procedure has been successfully completed.... 8/27/2012 5:28:09 AM Information MSExchangeIS (7916) SG2: The backup procedure has been successfully completed.... > >The output is incomplete while scheduling the same PS1 in windows task scheduler and following is the outcome. > >TimeGenerated EntryType Message > >------------- --------- ------- > >8/27/2012 10:30:00 PM Information MSExchangeIS (6076) SG1: The backup proced... > >8/27/2012 10:01:10 PM Information MSExchangeIS (6076) SG2: The backup proced... > >I need to know why the output is incomplete and why there is difference in executing PS1 from task scheduler? and how to correct it? > >Please suggest... I guess I'm missing the point. Neither of the two result in the complete text of the "Message". They're both truncated. If you want the complete text then don't use the default format. Get what you want from the event into a variable and then write that to your output. If $ev contains the event, then: $x=""|TimeGenerated,EntryType,Message $x.TimeGenerated = $ev.timegenerated $x.EntryType = $ev.eventtype $x.Message = $ev.message $list += $x # delare "$list = @()" beforehand At the end: $list|export-csv <filename> -notypeinfo --- Rich Matheisen MCSE+I, Exchange MVP --- Rich Matheisen MCSE+I, Exchange MVP
August 27th, 2012 5:49pm

Thanks Rich, I will try and let you know..
Free Windows Admin Tool Kit Click here and download it now
August 28th, 2012 4:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics