Skip to content

Instantly share code, notes, and snippets.

@romero126
romero126 / Invoke-PhiSilica
Last active April 30, 2026 19:48
Phi Silica
#Requires -Version 7.0
<#
.SYNOPSIS
Invoke the on-device Phi Silica AI model through the Windows App SDK.
.DESCRIPTION
Uses the Microsoft.Windows.AI.Text.LanguageModel API from the Windows App SDK
to run the Phi Silica small language model locally on Copilot+ PCs.
All inference runs on the device NPU — no cloud connection required.
@romero126
romero126 / ScriptBlockAstLdapFilter.ps1
Last active September 17, 2025 18:19
ScriptBlockAstLdapFilter
using namespace System.Collections.Generic
using namespace System.Management.Automation.Language
param (
[Parameter(Position = 0, ValueFromPipeline)]
$InputObject = { $_.SamAccountName -eq 'Clark*' }
)
class ScriptBlockLdapFilter : AstVisitor2 {
[System.Text.StringBuilder] $LdapFilter = [System.Text.StringBuilder]::new()
@romero126
romero126 / PostCommandLookupAction_CmdletInjection.ps1
Created August 30, 2025 05:39
PostCommandLookupAction_CmdletInjection
function script:Assert-PostCommandLookupAction_CmdletInjection {
begin {
Write-Host 'Proxy Command - Begin'
}
process {
Write-Host 'Proxy Command - Process'
}
end {
@romero126
romero126 / CommandLookup_ApplockerSignedScriptRestrictions.ps1
Last active June 4, 2025 19:36
Command LookupAccelerator (PreCommandLookupAction)
if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage') {
throw "This script requires `$ExecutionContext.SessionState.LanguageMode to be FullLanguageMode but got '$($ExecutionContext.SessionState.LanguageMode )'"
}
$global:PSPreCommandLookupAction += @{
Name = "ApplockerSignedScriptRestrictions"
Description = "This will bypass Applocker's Signed Script Restrictions by loading the script directly into memory as if it was dot sourced"
Filter = { $command -like "*.ps1" }
Priority = -1
StopSearch = $true
@romero126
romero126 / Get-PSBoundParameters.ps1
Last active May 28, 2025 06:01
Get-PSBoundParameters
function Get-PSBoundParameters {
<#
.SYNOPSIS
Get-PSBoundParameters
.DESCRIPTION
Get the bound parameters of the current command
.PARAMETER ParameterSetName
Filter the bound parameters by the specified ParameterSetName
class FrameBuffer : IDisposable {
[System.Int32] $Width
[System.Int32] $Height
[System.Boolean] $Disposed
hidden [System.Int32[]] $buffer
hidden [System.Runtime.InteropServices.GCHandle] $bufferHandle
hidden [System.Drawing.Image] $bitmap
FrameBuffer([System.Int32]$w, [System.Int32]$h) {
@romero126
romero126 / RemoteDesktopAppInstaller.ps1
Last active February 6, 2026 23:28
Invoke-RemoteDesktopAppInstaller
function Invoke-RemoteDesktopAppInstaller
{
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[System.Management.Automation.Runspaces.PSSession] $Session
)
$installShortcutDirectory = "$($env:USERPROFILE)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Remote App\"
$installResourceDirectory = "$($env:USERPROFILE)\AppData\Roaming\Microsoft\Workspaces\"
@romero126
romero126 / readme.md
Last active May 28, 2025 05:59
ConvertFrom-CidrToIPvNetwork
PS> ConvertFrom-CidrToIPvNetwork -vlsm "10.202.84.0/25"

IpAddress        : 10.202.84.0
AddressFamily    : InterNetwork
Prefix           : 25
Network          : 10.202.84.0
SubnetMask       : 255.255.255.128
BroadcastAddress : 255.255.255.255
@romero126
romero126 / Examples.md
Last active May 28, 2025 05:53
Monitor-Object

Example Expression

image

$splat = @{
    Title           = 'Monitor-Workflow';
    PropertyKey     = 'Value';
    Property        = 'Value', 'Iteration';
    InputPattern    = "(\d+)";
@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