Skip to content

Instantly share code, notes, and snippets.

View raandree's full-sized avatar
🏠
Working from home

Raimund Andrée [MSFT] raandree

🏠
Working from home
View GitHub Profile
@raandree
raandree / Get-KerberosTickets.ps1
Created February 15, 2022 10:53
Get all Kerberos tickets from all logon sessions
$sessions = klist sessions
$pattern = '\[(\d+)\] Session \d \d:(?<LowPart>0)x(?<HighPart>[a-f0-9]+)'
$sessions = foreach ($line in $sessions)
{
if ($line -match $pattern)
{
New-Object PSObject -Property @{
LowPart = $Matches.LowPart
HighPart = $Matches.HighPart
@raandree
raandree / DsGetDcNameWin32Demo.ps1
Created March 11, 2023 16:41
This script shows how to use a Win32 function (GetDcName) from PowerShell.
$code = @'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Test
@raandree
raandree / Get-NtlmLogonEvents.ps1
Created June 9, 2024 09:08
Detect NTLM v1 and v2 logons
$t1 = [datetime]::Today.AddHours(4).ToString('s')
$e = $null
$FilterXML = @"
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
(*[EventData[
Data[@Name="TargetDomainName"] != "Window Manager" and
Data[@Name="TargetDomainName"] != "Font Driver Host" and
Data[@Name="TargetDomainName"] != "NT AUTHORITY"
@raandree
raandree / Register-ScheduledTask2.ps1
Created January 13, 2025 18:39
This script registers a scheduled job to run the specified script on a schedule. It can register the job to run as local system or as the user who called this script.
<#
.SYNOPSIS
Registers a scheduled job to run the specified script on a schedule.
.DESCRIPTION
This script registers a scheduled job to run the specified script on a schedule. It can register the
job to run as local system or as the user who called this script.
.PARAMETER At
The time at which the job should be triggered. The format is 24 hours like 21:00.