イベントログにイベントを書き込むには、Write-EventLogを使用します。
構文
Write-EventLog -LogName <ログ名> -Source <ソース名> -EventID <イベントID> -Message <イベントメッセージ>
例
PS C:\work> Write-EventLog -LogName "TestLog" -Source "TestApp" -EventID 1001 -Message "This is a test message."
PS C:\work> Get-EventLog -LogName "TestLog"
Index Time EntryType Source InstanceID Message
----- ---- --------- ------ ---------- -------
4 1 09 18:48 Information TestApp 1001 This is a test message.
Get-EventLogで確認すると、エントリが追加されているのが分かります。スポンサーリンク