-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic-function.ps1
More file actions
27 lines (22 loc) · 828 Bytes
/
basic-function.ps1
File metadata and controls
27 lines (22 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#requires -version 5.1
#requires -RunAsAdministrator
#Functions do ONE thing and write ONE type of object to the pipeline
#this demo function lacks error handling
Function Get-CriticalEventLogEntry {
[CmdletBinding()]
Param(
[Parameter(
Position = 0,
Mandatory,
HelpMessage = 'Specify a Windows event log name like System.'
)]
[ValidateNotNullOrEmpty()]
[string]$LogName,
[Parameter(HelpMessage = 'Enter the name of the computer to query')]
[ValidateNotNullOrEmpty()]
[alias("System","CN")]
[string]$Computername = $env:COMPUTERNAME,
[int]$Count = 20
)
Get-WinEvent -FilterHashtable @{LogName = $LogName; Level = 2,3 } -MaxEvents $Count -ComputerName $Computername
} #close Get-CriticalEventLogEntry