Skip to content

Instantly share code, notes, and snippets.

@jborean93
jborean93 / NoGui.ps1
Last active May 16, 2025 20:37
Generates an exe called NoGui.exe that can spawn a hidden windows
<#
NOTE: Must be run in Windows PowerShell (5.1), PowerShell (7+) cannot create standalone exes.
This is designed to create a simple exe that can be used to spawn any console
application with a hidden Window. As NoGui.exe is a GUI executable it won't
spawn with an associated console window and can be used to then create a new
process with a hidden console window with the arguments it was created with.
By default, NoGui will spawn the child process with same stdio handles as
@jborean93
jborean93 / Get-WindowsUpdate.ps1
Last active May 15, 2025 21:34
Output a list of updates based on the criteria that you define
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Write-WUAError {
<#
.SYNOPSIS
Convert raw HRESULT codes to a human readable error.
.PARAMETER Exception
The COMException that the error code is from.
@jborean93
jborean93 / win_powershell_ssh.ps1
Last active May 9, 2025 11:30
Windows PowerShell SSH Remoting Stub
<#
.SYNOPSIS
Windows PowerShell SSH Server Subsystem Shim.
.DESCRIPTION
Used as a basic wrapper for Windows PowerShell that allows it to be used as a target for SSH based remoting sessions.
This allows a PowerShell client to target a Windows host through SSH without having PowerShell 7 installed.
.NOTES
This is experimental and used as a POC.
@jborean93
jborean93 / PSGet Publisher Checks.md
Last active May 8, 2025 14:27
Behaviour of signed PowerShell scripts

PSGet Code Signing

This is to try and document the behaviour around PowerShellGet/PSResourceGet code signing publisher behaviour.

Setup

The following code can be used to set up this scenario. This must be run as an administrator in Windows PowerShell.

Note: PowerShell uses implicit remoting for the New-SelfSignedCertificate which breaks the constains serialization. You must run this on Windows PowerShell.

@jborean93
jborean93 / Get-ItemMetadata.ps1
Created February 1, 2021 04:12
Get Windows Explorer metadata properties
# Copyright: (c) 2021, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Update-TypeData -TypeName 'Shell.Metadata' -DefaultDisplayPropertySet 'Name', 'Item type' -Force
Function Get-ItemMetadata {
<#
.SYNOPSIS
Get shell explorer metadata for a file.
@jborean93
jborean93 / Get-ServiceCredential.ps1
Last active April 10, 2025 20:25
Get's the username and password for installed Windows services
# Copyright: (c) 2019, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-ServiceCredential {
<#
.SYNOPSIS
Retrieve the username and plaintext password for all services installed on the local computer.
.DESCRIPTION
Will retrieve the username and plaintext password for the service(s) specified. This must be run as an
@jborean93
jborean93 / New-ScheduledTaskSession.ps1
Last active April 7, 2025 18:56
Creates a PSSession that targets a scheduled task process
# Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function New-ScheduledTaskSession {
<#
.SYNOPSIS
Creates a PSSession for a process running as a scheduled task.
.DESCRIPTION
Creates a PSSession that can be used to run code inside a scheduled task
@jborean93
jborean93 / New-ScheduledTaskTrigger.ps1
Created March 21, 2025 05:38
PowerShell script to create a state change, idle, or event trigger
# Copyright: (c) 2025, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function New-CommonTaskTriggerProp {
[OutputType([hashtable])]
[CmdletBinding()]
param (
[Parameter()]
[switch]
$Disable,
@jborean93
jborean93 / Get-LapsADUpdateTime.ps1
Last active March 25, 2025 07:39
Gets the LAPS UpdateTime attribute for AD computer accounts
# Copyright: (c) 2025, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-LapsADUpdateTime {
<#
.SYNOPSIS
Gets the Windows LAPS Update Time.
.DESCRIPTION
Gets the Windows LAPS Update Time for the specified computer account. The output value is a DateTime object representing the update time as a UTC date time.
@jborean93
jborean93 / GetDiskFreeSpaceExW.ps1
Created March 18, 2025 21:15
Ctypes call to GetDiskFreeSpaceExW
$k32 = New-CtypesLib Kernel32.dll
$free = $total = $totalFree = [int64]0
$res = $k32.SetLastError().GetDiskFreeSpaceExW(
$k32.MarshalAs('C:\', 'LPWStr'),
[ref]$free,
[ref]$total,
[ref]$totalFree)
if (-not $res) {
throw [System.ComponentModel.Win32Exception]::new($k32.LastError)