search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
How to create event log folder with PowerShell
Posted in Windows Powershell | 4 Comments | 7,371 views | 28/05/2015 10:47

Following creates a new event log folder called “yusufozturk” in your Application Log Folder.

1
2
3
4
5
# Create Event Log
New-EventLog -LogName "yusufozturk" -Source "Hyper-V" -EA SilentlyContinue
 
# Limit Event Log Properties
Limit-EventLog -LogName "yusufozturk" -OverflowAction "OverWriteAsNeeded" -MaximumSize 100MB -EA SilentlyContinue

As you see, you can also set OverFlowAction and MaximumSize.


Comments (4)

Mike

September 25th, 2015
17:58:01

No it doesn’t. I am in the process of trying to figure this out now. All your code does is create an event log named “yusufozturk”. if you look in the “C:\Windows\System32\winevt\Logs” folder you will notice a log file called “yusufozturk.evtx”. A folder holds a collection of logs. A folder is similar to what Microsoft has under the “Application and Services Logs”. Which it should be stated that the “Application and Services Logs” is the default location for all newly made logs. For instance Lets say we want to store something under a Folder called MyLogs. First rule is that a folder name can’t contain spaces, or not that I have seen so far. Then let’s say you want to save your “yusufozturk” log in the MyLogs directory. So your directory structure will be:

“Application and Services Logs”->”MyLogs”->”yusufozturk”

When it saves the log to the system in the “C:\Windows\System32\winevt\Logs” folder it will save the file like this MyLogs%4yusufozturk.evtx.

When creating a log under a folder it saves the file with a “-” as a separator for the multiple directories. As you add to the directory structure like:

“Application and Services Logs”->”MyLogs”->”Applications”->”yusufozturk”

The new log gets saved as: MyLogs-Applications%4yusufozturk.evtx

As you can see once you get into a Subdirectory of the primary directory the file gets saved with a hyphen separating the 2 directories.

I yet have an answer to how Microsoft, Cisco, and HP figured out how to add actual subdirectories, but soon as I figure it out I will post it all over the web. I have already tried using C#, now I am looking up methods in PowerShell.

Unfortunately there are too many people on the web that don’t have a clue on how Event Logs work and give the exact same answer as you did for how to create a folder under the “Application and Services Logs”.


admin

October 4th, 2015
17:14:53

Hi Mike,

You can use same C# code in PowerShell. You don’t have to look native commandlets for that. Thanks for the clarification btw. These are quick notes, especially for myself to find it quick next time when I need. So I share them in my own way. But everybody can use my scripts in their own way.

Thanks for sharing your experience.

Yusuf


Peter

October 15th, 2015
09:06:11

Hello,
please send me a simple sample for this task
“Application and Services Logs”->”MyLogs”->”Applications”->”yusufozturk”
into a Subdirectory of the primary directory
Peter


korta

July 7th, 2017
11:02:29

Merhabalar çok işime yaradı. Teşekkür ediyorum.



Leave a Reply