0

I try to use PsLogList to import some eventlogs. What is strage is that ever second time I run it, there is no error-message...

Here is the part where I have problems with:

$psloglist = "C:\Users\e-cedric.esch\Downloads\PSTools\PsLogList.exe"
$log = &$psloglist $($serverr) -u $($this.elogusr) -p $($this.elogpwd) -s -x -t \t $($logname)

Error-Message I get:

At C:\Users\systemCESCH\Desktop\test1.ps1:line:38 char:10
+   $log = &$ <<<< psloglist $($serverr) -u $($this.elogusr) -p $($this.elogpwd) -s -x -t \t $($logname)

PsLoglist v2.71 - local and remote event log viewer
Copyright (C) 2000-2009 Mark Russinovich
Sysinternals - www.sysinternals.com

At C:\Users\systemCESCH\Desktop\test1.ps1:line:38 char:10
+   $log = &$ <<<< psloglist $($serverr) -u $($this.elogusr) -p $($this.elogpwd) -s -x -t \t $($logname)

Error-Message I get when I debug:

Exception calling "getELog" with "2" argument(s): "Program 'PsLogList.exe' failed to execute: The WriteObject and WriteError methods cannot be called after the pipeline has been closed. Please cont
act Microsoft Support Services.
At C:\Users\systemCESCH\Desktop\test1.ps1:38 char:10
+     $log = & <<<< $psloglist $($serverr) -u $($this.elogusr) -p $($this.elogpwd) -s -x -t \t $($logname)."
At C:\Users\systemCESCH\Desktop\test1.ps1:78 char:34
+ write-output $ELogHandler.getELog <<<< ("PWLU0W987","Application")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ScriptMethodRuntimeException

Btw., I'm using PowerGUI Script Editor v. 3.8.0.129

Dobi
  • 125
  • 5
  • 15
  • powershell has several built in cmdlet to query event logs, is there a reason to use an external program ? – Loïc MICHEL Sep 17 '14 at 13:08
  • Maybe a stupid answert, but I use that one because I know that it works on all our servers because I already used this tool before. (Btw., I know that also Get-EventLog and Get-WinEvent exists, but never used them before.) Apart from that I whant to find out what the problem is and why this error happens. ;) – Dobi Sep 17 '14 at 13:43

2 Answers2

0

try this :

$prog="psloglist"      
$a="\\$serverr  -u $user -p $password -s -x"         
Start-Process $prog $a -noNewWindow

it's worth reading that post How to run an EXE file in PowerShell with parameters with spaces and quotes

Community
  • 1
  • 1
Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103
  • "This command cannot be executed due to the error: The system cannot find the file specified." Btw., if I give the full path instead of "psloglist", nothing happens (no error, nothing else). – Dobi Sep 17 '14 at 14:12
  • start from the begining : are you able to open powershell prompt and run pslogist interectivly ? without and with parameters ? BTW this is working on my win7 x64, with psloglist.exe in %windir%\system32 – Loïc MICHEL Sep 17 '14 at 14:15
  • Ok, thx! ;) No, that's why I'm using the full path where the file is located. "The term 'psloglist' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again." – Dobi Sep 17 '14 at 14:29
0

Are you running your command in the ISE? Have you tested it in a console? I've run into issues with the PsTools before when using the ISE and have gotten them to work properly from the powershell console directly.

I just tested this simplified version:

&"C:\Temp\PSTools\PsLogList.exe" -accepteula \\somecomputer -u domain\myusername -p mypassword

It didn't work in the ISE but it worked in the console.

I would suggest trying to simplify your command and test it in the console as well (if you're using the ISE).

Kris Powell
  • 131
  • 5
  • Hmm, yes, same for mee, using PowerGUI Script Editor v3.8.0.129 it didn't worked (apart from every second time I ran it), but in the console (v1.0) it's no problem. Strange... – Dobi Sep 17 '14 at 14:41