Skip to content

Instantly share code, notes, and snippets.

View mattcargile's full-sized avatar

Matt Cargile mattcargile

  • Baton Rouge, LA
View GitHub Profile
@jborean93
jborean93 / Split-ExeArgument.ps1
Last active June 4, 2024 01:24
Splits the input string using the Win32 argument splitter
# Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
#Requires -Module Ctypes
Function Split-ExeArgument {
[OutputType([string])]
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
@jborean93
jborean93 / Get-FileProcess.ps1
Created May 30, 2024 23:18
Gets the process ids that has the requested file(s) opened
# Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
#Requires -Module Ctypes
#Requires -Version 7.3
Function Get-FileProcess {
<#
.SYNOPSIS
Get the process that has opened the requested file.
function Get-BoundParameters {
<#
.DESCRIPTION
Get-BoundParameters is a helper function that returns a hashtable of the bound parameters of the calling function.
difference between $PSBoundParameters is that it gets default value from param block as well.
.PARAMETER IncludeCommon
include the common parameters
@jborean93
jborean93 / NoGui.ps1
Last active May 24, 2024 15:49
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.
The arguments after -- will be used as the new process, for example
C:\path\NoGui.exe -- pwsh.exe
@romero126
romero126 / Import-ModuleManually
Created July 19, 2023 18:20
Import-Module Manually
function Import-ModuleManually {
param(
[Parameter(Mandatory=$true)]
[string]$Module,
[Parameter(Mandatory=$false)]
[switch]$Force
)
$moduleExists = Get-Module -Name $Module -All
@Jaykul
Jaykul / Grouping.psm1
Created April 14, 2023 22:18
Expand and Group objects when they have (or could be deduped with) a single array property
filter Expand-Property {
<#
.SYNOPSIS
Expands an array property, creating a duplicate object for each value
.EXAMPLE
[PSCustomObject]@{ Name = "A"; Value = @(1,2,3) } | Expand-Property Value
Name Value
---- -----
A 1
@JustinGrote
JustinGrote / EasyFormat.psm1
Last active June 7, 2024 18:41
A proxy for Format-Table to apply the resultant view or save it as a format definition
using namespace System.Management.Automation
using namespace System.Management.Automation.Runspaces
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Text
using namespace System.Xml
using namespace System.IO
$ErrorActionPreference = 'Stop'
$SCRIPT:RunspaceFormats = [Runspace]::DefaultRunspace.InitialSessionState.Formats
using module ActiveDirectory
using namespace System.Reflection
function Convert-ADFilter {
<#
.SYNOPSIS
Converts PowerShell-style filters used by the AD module into LDAP filters.
.DESCRIPTION
Convert-ADFilter uses the QueryParser from the AD module to convert PowerShell-style filters into LDAP
@santisq
santisq / Get-TreeOrganizationalUnit.ps1
Last active November 29, 2022 21:59
tree function for AD OUs and Containers
using namespace System.Collections.Generic
using namespace Microsoft.ActiveDirectory.Management
using namespace System.Management.Automation
function Get-TreeOrganizationalUnit {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string] $Identity,
@jborean93
jborean93 / Get-WTSSessionInfo.ps1
Last active March 26, 2024 14:49
Tries to replicate qwinsta but return structured objects
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-WTSSessionInfo {
<#
.SYNOPSIS
Enumerates sessions on a Windows host.
.DESCRIPTION
Enumerates all the sessions available on a Windows host through the WTSEnumerateSessionsExW API.