Skip to content

Instantly share code, notes, and snippets.

@lansalot
lansalot / Get-GPOWithoutUnauthenticatedUsers.ps1
Created January 16, 2020 09:38
Find all group policyies without Authenticated Users permissions
Get-GPO -All | ForEach-Object {
# Test if Authenticated Users group have at least read permission on the GPO
if ('S-1-5-11' -notin ($_ | Get-GPPermission -All).Trustee.Sid.Value) {
$_
}
} | Select DisplayName
@lansalot
lansalot / Get-ActiveWindowProcessID.ps1
Created January 24, 2019 23:26
Find the active window process owner
Add-Type @"
using System;
using System.Runtime.InteropServices;
public static class Win32Api
{
[System.Runtime.InteropServices.DllImportAttribute( "User32.dll", EntryPoint = "GetWindowThreadProcessId" )]
public static extern int GetWindowThreadProcessId ( [System.Runtime.InteropServices.InAttribute()] System.IntPtr hWnd, out int lpdwProcessId );
[System.Runtime.InteropServices.DllImportAttribute( "User32.dll", EntryPoint = "GetForegroundWindow" )]
public static extern IntPtr GetForegroundWindow();
}