- (a) get-winevent is slow for high volume queries
- (b) modules so encapsulate their variables in functions that I could not find how to call all functions globally from an internal or external script.
Historic blog. No longer active. See Also http://horizontal-logic.blogspot.com for more Powershell code. AS of 2/27/2014 all Scripts are PS 4.0.
Showing posts with label Sorting/Searching for Events by UserID. Show all posts
Showing posts with label Sorting/Searching for Events by UserID. Show all posts
Thursday, August 11, 2011
Sorting Windows events by UserID: Part II (Building a Module)
I am a bit late to some v2.0 functionality. I made my first attempt at creating a module, in this case a six function script that queries general information from an event log. I ran into at least two problems:
Friday, July 29, 2011
Sorting Windows events by UserID
Sorting Windows events by UserID is a critical piece of auditing. In the code and examples below, I concentrate on:
$Logs="System","Application","Microsoft-Windows-GroupPolicy/Operational"
purposefully leaving out the Security log. We can create a simple function that allows us to check all events logs on any machine sorted by file size:
function CheckEventLogsBySize
{
get-winevent -listlog * | Sort -desc FileSize |
ft -auto LogName,@{Label="FileLogSize(MB)"; Expression={$_.FileSize/1MB}},@{Label="MaxLogSize(MB)"; Expression={$_.MaximumSizeINBytes/1MB}},LastWriteTime,IsLogFull
}
$Logs="System","Application","Microsoft-Windows-GroupPolicy/Operational"
purposefully leaving out the Security log. We can create a simple function that allows us to check all events logs on any machine sorted by file size:
function CheckEventLogsBySize
{
get-winevent -listlog * | Sort -desc FileSize |
ft -auto LogName,@{Label="FileLogSize(MB)"; Expression={$_.FileSize/1MB}},@{Label="MaxLogSize(MB)"; Expression={$_.MaximumSizeINBytes/1MB}},LastWriteTime,IsLogFull
}
Subscribe to:
Posts (Atom)