Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-EventLogSource {
- param ([Parameter(Mandatory, Position = 0)][SupportsWildcards()][string]$Name,
- [Parameter(Position = 1)][string]$LogName)
- $x = Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Services\EventLog -ErrorAction Ignore |
- ? PSChildName -NE 'Security' | % PSChildName -pv LN |
- % {
- Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\$LN -ErrorAction Ignore |
- % PSChildName | % {
- [PSCustomObject]@{ Source = $_; LogName = $LN }
- }
- }
- if ($LogName) { $x = $x | ? LogName -EQ $LogName }
- $x | ? Source -Like $Name
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement