Skip to content

Instantly share code, notes, and snippets.

View KurtDeGreeff's full-sized avatar

Kurt De Greeff KurtDeGreeff

View GitHub Profile
@jborean93
jborean93 / Appx-Server2025.ps1
Created November 10, 2024 21:40
Fix Appx in PSRemoting for Server 2025
# Server 2025 fails to run Get-AppxPackage and other DISM module commands in
# a PSRemoting (psrp) session as it has a dependency on some dll's not present
# in the GAC and only in the powershell.exe directory. As PSRP runs through
# wsmprovhost.exe, it fails to find those dlls. This hack will manually load
# the 4 required dlls into the GAC. This is a hack and should be removed in the
# future if MS fix their bug on 2025.
Add-Type -AssemblyName "System.EnterpriseServices"
$publish = [System.EnterpriseServices.Internal.Publish]::new()
@awakecoding
awakecoding / Get-AadJoinInformation.ps1
Created August 8, 2023 14:21
Get Azure AD (Entra ID) Join Information without dsregcmd
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
public enum DSREG_JOIN_TYPE {
DSREG_UNKNOWN_JOIN = 0,
DSREG_DEVICE_JOIN = 1,
DSREG_WORKPLACE_JOIN = 2
}
@SMSAgentSoftware
SMSAgentSoftware / Get-WindowsUpdateHistory.ps1
Last active May 31, 2023 10:09
PowerShell 'one-liner' to get Windows Update history using the PackageManagement module
Get-Package -ProviderName msu |
Select Name,
@{l='UpdateType';e={
If ($_.Name -match "Antivirus" -or $_.Name -match "antimalware")
{"Definition Update"}
ElseIf ($_.Metadata.Item("SupportUrl") -match "target=hub")
{"Driver Update"}
ElseIf ($_.Summary -match "latest version of Windows")
{"Feature Update"}
ElseIf ($_.Name -match "Malicious Software Removal" -or $_.Name -match "Intelligence Update")
@api0cradle
api0cradle / check_vulnerabledrivers.ps1
Created May 19, 2023 14:13
A quick script to check for vulnerable drivers. Compares drivers on system with list from loldrivers.io
# Simple script to check drivers in C:\windows\system32\drivers against the loldrivers list
# Author: Oddvar Moe - @oddvar.moe
$drivers = get-childitem -Path c:\windows\system32\drivers
$web_client = new-object system.net.webclient
$loldrivers = $web_client.DownloadString(" https://www.loldrivers.io/api/drivers.json") | ConvertFrom-Json
Write-output("Checking {0} drivers in C:\windows\system32\drivers against loldrivers.io json file" -f $drivers.Count)
foreach ($lol in $loldrivers.KnownVulnerableSamples)
{
@JustinGrote
JustinGrote / README.MD
Last active September 6, 2024 04:02
A proxy for Format-Table to apply the resultant view or save it as a format definition

TypeFormat

This module provides an improved Format-Table that lets you persist the resultant Format-Table view either to the current session or to a .ps1xml formatting file.

This module requires PowerShell 7.2+, however the generated XML format files can be used with earlier versions.

Quick Start

PS> Get-Date
@JustinGrote
JustinGrote / Get-MgServicePrincipalPermission.ps1
Last active November 6, 2024 10:21
Get a list of application and delegated permissions for a service principal, similar to what the Azure Portal shows
#requires -version 7 -module Microsoft.Graph.Applications
using namespace Microsoft.Graph.PowerShell.Models
using namespace System.Collections.Generic
enum MicrosoftGraphServicePrincipalType {
Application
Delegated
}
class MgServicePrincipalPermission {
@SMSAgentSoftware
SMSAgentSoftware / Convert-CCMLogToObjectArray.ps1
Created June 22, 2022 14:18
PowerShell function to convert a log formatted with the ConfigMgr log schema into an array of objects
## PowerShell function to convert a log formatted with the ConfigMgr log schema into an array of objects
# Parameters:
# - LogPath. The full path to the log file
# - LineCount. The number of log entries to return, starting from the BOTTOM up (ie most recent back). Default: 500.
function Convert-CCMLogToObjectArray {
Param ($LogPath,$LineCount = 500)
# Custom class to define a log entry
class LogEntry {
@fearthecowboy
fearthecowboy / FluentConsole.ps1
Created June 9, 2022 19:16
FluentConsole for PowerShell
<##
FluentConsole Functions
(C) 2022 Garrett Serack
License: MIT
Usage:
dot source this into your script (. FluentConsole.ps1 )
and then you can use the colon-prefixed functions.
You can separate colon-function calls with ';' or '|' or a newline.
@JustinGrote
JustinGrote / Select-StringMatch.ps1
Last active August 19, 2024 19:01
A companion to Select-String to more easily retrieve the results of capture groups, similar to $matches but pipeline friendly.
filter Select-StringMatch {
<#
.SYNOPSIS
A companion to select-string to quickly fetch the value of a capture group, named or indexed
.DESCRIPTION
With -replace or -match we have the simple $matches['group'] syntax, but this doesn't really exist for Select-String
and the typical options are not pipeline friendly. The default object returned from Select-String is not that friendly
either if all you want is the value(s) of a capture group to then pipe to another command. This is basically a pipeline
friendly version of $matches.
@SMSAgentSoftware
SMSAgentSoftware / Get-CurrentPatchInfo.ps1
Last active March 20, 2025 09:47
Gets the current software update level of a Windows 10/11 workstation and compares with the latest available updates. Can also list all available updates for the current build.
[CmdletBinding()]
Param(
[switch]$ListAllAvailable,
[switch]$ExcludePreview,
[switch]$ExcludeOutofBand
)
$ProgressPreference = 'SilentlyContinue'
Function Get-MyWindowsVersion {
[CmdletBinding()]