Responsive forms with remote event log

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
DarkLite1
Posts: 102
Last visit: Wed Jan 06, 2021 4:12 am

Responsive forms with remote event log

Post by DarkLite1 »

We're have a remote server hosting a Windows Event Log where we keep track of all the actions our scripts take. When we want to write to it, we simply use:
  1. Write-EventLog -LogName $Name-ComputerName $Server -Source $Source -Message $Message  -EventId $ID
This works perfectly fine when time is not an issue. But when we use this in our responsive forms created in PowerShell Studio, it takes 0.8 seconds to perform. This hinders of course the user experience as it slows it down. Starting a new job takes 0.7 seconds, so that's not really an improvement.

Is there a way to avoid the waiting time for the CmdLet? I've thought about the following options:

1. Using Start-Process, but this might bring up another PowerShell pop-up window which is not desirable.
2. Write messages to the local Event Log and make a copy script to copy these entries to the central server (assuming that writing locally it's faster)
3. Create a job that continuously runs with the sole purpose of writing stuff to the log on the central server. But I don't know how to feed it new data once it's launched.
4. User runspaces as described here: https://smsagent.wordpress.com/2015/09/ ... lications/ But I don't know how to implement that.

Any input on this is more then welcome. Thank you for your help.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Responsive forms with remote event log

Post by jvierra »

Events should be written to the local log and then there would be no delay. Use log aggregation to collect logs into a remote system.

Consider what happens t the users if the remote system fails to work correctly. All users would be forced to wait for 2 minutes or more ad the log messages would all be lost.
User avatar
DarkLite1
Posts: 102
Last visit: Wed Jan 06, 2021 4:12 am

Re: Responsive forms with remote event log

Post by DarkLite1 »

Thank you jvierra, you are absolutely right. Tested it locally and it's a lot less hassle then playing with RunSpaces and other things. Thanks to this link https://www.loggly.com/ultimate-guide/c ... dows-logs/ I've managed to set up the 'Forwarded events' to have all the events available on one centralized server.

And this link https://social.technet.microsoft.com/Fo ... management allowed me to get rid of the following message once collected:
The description for Event ID 4 from source MyApp cannot be found. Either the component
that raises this event is not installed on your local computer or the installation is corrupted. You can
install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:
You're right, when the centralized logging server goes down we're not impacting the users anymore. Thanks again for the great advice.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Responsive forms with remote event log

Post by jvierra »

That's the design. No muss. No fuss.

Good luck.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked