2017-10-05 34 views
0

フォームには(PowerShellで)Windowsフォームがあり、フォームにはonclickイベントのボタンがありますが、onclickのコマンドは実行されません。私はなぜそれがsepratleyを実行することができるので、わからない。私のsciptblockはここにあります:Powershell WindowsフォームのonClickイベント

[void][reflection.assembly]::loadwithpartialname("System.Windows.Forms") 
$form = New-Object System.Windows.Forms.Form 
$form.Width = 500 
$form.Height = 200 
$form.formborderstyle = 3 
$form.StartPosition = "CenterScreen" 

$button1 = New-Object System.Windows.Forms.Button 
$button1.Text = "Search" 
$button1.Height = 25 
$button1.Width = 85 
$button1.Top = 100 
$button1.Left = 25 
$button1_OnClick = 
    { 
     Get-EventLog -LogName Security -After $a2.Value.Date | Where-Object 
{$_.EventID -eq "4800" -or $_.EventID -eq "4801"} | Format-Table 
    } 
$button1.add_Click($button1_OnClick) 
$form.Controls.Add($button1) 

$form.ShowDialog() 

私の問題を解決するのを助けてください。 ありがとうございます!あなたは$あなたがどのように出力テーブルをすることを決定したdidntの

Get-EventLog -LogName Security -After $a2.Value.Date 

セカンドでを定義していませんでした

+0

あなたは$ A2 – ArcSet

答えて

1

2物事

。あなたは

Get-EventLog -LogName Security -After $a2.Value.Date | Where-Object{$_.EventID -eq "4800" -or $_.EventID -eq "4801"} | Format-Table | Out-Host 
+0

申し訳定義didntの...のような何かを行うことができ、私は$の定義を示すために間違いがあったが、あなたのanswareはで私のためによかったです| Out-Hostパイプライン!ありがとうArcSet! –

関連する問題