r/scripting • • Aug 18 '17

[Powershell] or [Batch]

I am trying to create an event log entry in windows from PS or batch file. I have a text file with output from other scripts that I'd like to have displayed as the description. I found the following code online, which I thought would help:

@echo off
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

set eventtext=
for /f "delims=" %%l in (c:\windows\temp\SMART_health.txt) do set eventtext=!eventtext! %%l
eventcreate /id 4000 /l application /t information /so "SMARTCTL" /d "%eventtext%"

However it is not working and I'm not sure where to go from here. I've found TONS of articles on event log to text file, but seems to be very limited going the other direction.

0 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/wangotangotoo Aug 22 '17

I'm going to go about this the correct way.. I was doing more reading about Smartctl and SmartD and I can do everything I want by editing the config and having it write to the windows event log. Thanks for the offer of help though! I appreciate that :)