Issue with herestring as a job scriptblock


hello,

i need little help.  building one of two herestrings , using scriptblock start job logfiles.  things work fine except when try add clause end of second heresting filter eventid.  variables coming winform.   if don't specify eventid in form first herestring runs fine if specify eventid errors on second herestring.  not sure why throwing mouse event.   my error is

the term 'system.windows.forms.mouseeventargs.eventid' not recognized name...

thanks ..." 

 


$entryfilter = "error, warning, information"

if (($txteventid.text -eq $null) -or ($txteventid.text -eq "")) 
{
$cmd = @"   
get-eventlog -logname application -computername $($txtcname.text) `
-newest $($nupdnlogcount.text) -entrytype $(@($entryfilter)) |
select-object -property timegenerated, entrytype, source, eventid, message
"@
}
else
{
$cmd = @"   
get-eventlog -logname application -computername $($txtcname.text) `
-newest $($nupdnlogcount.text) -entrytype $(@($entryfilter)) |
select-object -property timegenerated, entrytype, source, eventid, message |
{ $_.eventid -eq $($txteventid.text) }         ### <<<<<<<  error line
"@
}

$sb = [scriptblock]::create($cmd)                

start-job -scriptblock $sb  

escape char $:

  { `$_.eventid -eq $($txteventid.text) }  




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Domain migration ERR3:7075 Failed to change domain affiliation, hr=8007054a This operation is only allowed for the Primary Domain Controller of the domain

How do a find data in one file, search for it in another file and if not found, write a custom message to another file