Skip to content

Instantly share code, notes, and snippets.

@vexx32
vexx32 / PowershellLoopBehavior.md
Last active November 15, 2024 18:59 — forked from JustinGrote/PowershellLoopBehavior.md
Reference Table for Loop Behavior in Powershell
Loop Return Continue Break
Normal Expectation Exit Scope Next Item Exit Loop
.foreach{} Next Item Break Scopes / Next Item of Parent Loop Break Scopes / Exit Parent Loop
foreach ($y in $x) Exit Scope Next Item Exit Loop
for ($i;$i -lt 5;$i++) Exit Scope Next Item Exit Loop
Foreach-Object -InputObject @() Next Item Break Scopes / Next Item of Parent Loop Break Scopes / Exit Parent Loop
Switch Exit Scope Next Item Exit Switch
While
@ninmonkey
ninmonkey / VS Code snippets and examples.jsonc
Last active July 15, 2024 18:41
vs code snippet patterns
{
/*
description:
Examples of different input types
this isn't an actual snippet file to use
it's an example template
New: Snippet variables
https://code.visualstudio.com/updates/v1_53#_new-snippet-variables
class ConstrainedVariableInterpolation : System.Management.Automation.Language.AstVisitor {
hidden [Hashtable] $Property
[System.Collections.Generic.List[PSCustomObject]] $Result
hidden [System.Management.Automation.Language.Ast] $Ast
[System.Management.Automation.Language.AstVisitAction] CheckForPostAction([System.Management.Automation.Language.Ast] $ast, [System.Management.Automation.Language.AstVisitAction] $action)
{
throw 'CheckForPostAction not supported'
}
@jborean93
jborean93 / PSGet Publisher Checks.md
Last active June 23, 2025 04:50
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.

@Hugoberry
Hugoberry / .block
Last active July 8, 2022 21:34 — forked from drzax/.block
Narrative Charts
license: mit
scrolling: true
height: 300
@jborean93
jborean93 / Get-ItemMetadata.ps1
Created February 1, 2021 04:12
Get Windows Explorer metadata properties
# Copyright: (c) 2021, Jordan Borean (@jborean93) <[email protected]>
# 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.
@romero126
romero126 / ConstrainedVariableInterpolation
Last active May 9, 2021 22:44
ExpandStringVisitor: Context locked String Interpolation using AstVisitor
class ConstrainedVariableInterpolation : System.Management.Automation.Language.AstVisitor {
hidden [Hashtable] $Property
[System.Collections.Generic.List[PSCustomObject]] $Result
hidden [System.Management.Automation.Language.Ast] $Ast
[System.Management.Automation.Language.AstVisitAction] CheckForPostAction([System.Management.Automation.Language.Ast] $ast, [System.Management.Automation.Language.AstVisitAction] $action)
{
throw 'CheckForPostAction not supported'
}
#Import-Module "$PSScriptRoot\..\Module\WindowsPresentationFramework" -Force
. "$PSScriptRoot\WindowsPresentationFramework.ps1"
#Region ThreadSafe
# Bind Variables
[WindowsPresentationFrameworkThreadSafe()]
[PSObject] $Variable = "Herro World from Proxy Scope"
[WindowsPresentationFrameworkThreadSafe()]
$Sync = [hashtable]::Synchronized(@{})
@mislav
mislav / workflows-automerge.yml
Last active August 19, 2024 15:40
Using GitHub CLI from GitHub Actions
name: Auto-merge
on:
pull_request:
types: [opened]
jobs:
automerge:
runs-on: ubuntu-latest
@jborean93
jborean93 / Get-Shortcut.ps1
Created March 15, 2021 06:15
Get information about a Windows shortcut (lnk) files
# Copyright: (c) 2021, Jordan Borean (@jborean93) <[email protected]>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-Shortcut {
[CmdletBinding(DefaultParameterSetName='Path')]
param (
[Parameter(
Mandatory = $true,
Position = 0,
ValueFromPipeline = $true,