EventLog/Get-EventKerberosTGTRequest.ps1
function Get-EventKerberosTGTRequest { <# .SYNOPSIS Short description .DESCRIPTION Long description .EXAMPLE PS C:\> <example usage> Explanation of what the example does .INPUTS Inputs (if any) .OUTPUTS Output (if any) .NOTES General notes #> [CmdletBinding(DefaultParameterSetName = 'Local')] param ( # Log name for where the events are stored. [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string] $LogName = 'Security', # The name of the account for which logon was performed [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $UserName, # SID of account that reported information about successful logon or invokes it. [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $UserSID, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $TicketOptions, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $ServiceName, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $PreAuthType, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $Status, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $TicketEncryptionType, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $CertIssuerName, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $CertSerialNumber, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $CertThumbPrint, # Specifies the path to the event log files that this cmdlet get events from. Enter the paths to the log files in a comma-separated list, or use wildcard characters to create file path patterns. Function supports files with the .evtx file name extension. You can include events from different files and file types in the same command. [Parameter(Mandatory=$true, Position=0, ParameterSetName="file", ValueFromPipelineByPropertyName=$true)] [Alias("FullName")] [ValidateNotNullOrEmpty()] [SupportsWildcards()] [string[]] $Path, # Gets events from the event logs on the specified computer. Type the NetBIOS name, an Internet Protocol (IP) address, or the fully qualified domain name of the computer. # The default value is the local computer. # To get events and event logs from remote computers, the firewall port for the event log service must be configured to allow remote access. [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Remote')] [string[]] $ComputerName, # Specifies a user account that has permission to perform this action. # # Type a user name, such as User01 or Domain01\User01. Or, enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will # be prompted for a password. If you type only the parameter name, you will be prompted for both a user name and a password. [Parameter(Mandatory = $false, ParameterSetName = 'Remote')] [Management.Automation.PSCredential] [Management.Automation.CredentialAttribute()] $Credential, # Specifies the maximum number of events that are returned. Enter an integer. The default is to return all the events in the logs or files. [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [int64] $MaxEvents, # Stsrttime from where to pull events. [Parameter(Mandatory = $false)] [datetime] $StartTime, # Stsrttime from where to pull events. [Parameter(Mandatory = $false)] [datetime] $EndTime, # Changes the default logic for matching fields from 'and' to 'or'. [Parameter(Mandatory = $false)] [switch] $ChangeLogic, # Changes the query action from inclusion to exclusion when fields are matched. [Parameter(Mandatory = $false)] [switch] $Suppress ) begin { $Params = $MyInvocation.BoundParameters if ($EventLogonType.Count -gt 0) { $LogonType = @() foreach($ltype in $EventLogonType) { switch ($ltype) { 'Interactive' {$LogonType += 2} 'Network' {$LogonType += 3} 'Batch' {$LogonType += 4} 'Service' {$LogonType += 5} 'Unlock' {$LogonType += 7} 'NetworkCleartext' {$LogonType += 8} 'NewCredentials' {$LogonType += 9} 'RemoteInteractive' {$LogonType += 10} 'CachedInteractive' {$LogonType += 11} Default {} } } $Params.Remove("EventLogonType")| Out-Null $Params.Add("LogonType",$LogonType) | Out-Null } if ($Params.Keys -contains "UserName") { $Params.Remove("UserName") | Out-Null $Params.Add('TargetUserName', $UserName) | Out-Null } if ($Params.Keys -contains "UserSID") { $Params.Remove("UserSID") | Out-Null $Params.Add('TargetUserSid', $UserSID) | Out-Null } if ($Params.Keys -contains "UserDomain") { $Params.Remove("UserDomain") | Out-Null $Params.Add('TargetDomainName', $UserDomain) | Out-Null } if ($Params.Keys -contains "LogonId") { $Params.Remove("LogonId") | Out-Null $Params.Add('SubjectLogonId', $LogonId) | Out-Null } } process { Search-EventLogEventData -EventId 4768 -ParamHash $Params -Provider "Microsoft-Windows-Security-Auditing" -RecordType "KerberosTGTRequest" } end {} } |