Skip to content

Instantly share code, notes, and snippets.

View schittli's full-sized avatar

Tom-- schittli

  • Biel / Bienne, Switzerland
  • 20:36 (UTC +02:00)
View GitHub Profile
@jdhitsolutions
jdhitsolutions / EverythingPrompt.ps1
Last active July 30, 2019 23:14
A "kitchen sink" PowerShell prompt. This only works on Windows platforms, including PowerShell Core.
<#
This may not work properly or completely in all PowerShell hosts. Because the function
relies on Get-CimInstance it will not work on Linux platforms.
It is also admittedly not speedy as it is doing a lot of stuff, although there is an
attempt to cache some information which gets updated every 15 minutes.
To use, dot source this script in your PowerShell profile to make it your default prompt.
Sample prompt:
@Jaykul
Jaykul / Hide-FromDebugger.ps1
Created July 29, 2017 23:01
Have you ever wished you could hide a few commands from the PowerShell step-through?
<#
.SYNOPSIS
Wrap commands with DebuggerNonUserCode attribute to prevent the PowerShell debugger stepping into them
.DESCRIPTION
Generates proxy functions that wrap the original commands, and put an attribute on the proxy to prevent the debugger stopping.
.EXAMPLE
Get-Command -Module Pester | Hide-FromDebugger
Hides all pester functions from the debugger, so you can debug in your code without stepping into Pester functions.
#>
@Jaykul
Jaykul / New-LoggingCommand.ps1
Created July 27, 2017 23:44
Something I need to add to the Information Module
[CmdletBinding()]
param(
[System.Management.Automation.CommandMetadata]
$Command
)
begin {
$ProxyFactory = [System.Management.Automation.ProxyCommand]
<#
class TraceInformation {
[String]$Message
@Jaykul
Jaykul / CredentialManagement.cs
Last active March 27, 2019 14:48
Trying to add some features to BetterCredentials
// Copyright (c) 2014, Joel Bennett
// Licensed under MIT license
using System;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32.SafeHandles;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace CredentialManagement
{
@Jaykul
Jaykul / HuddledTricks.psm1
Last active July 11, 2024 15:21
Stupid PowerShell Tricks
#Requires -version 2.0
## Stupid PowerShell Tricks
###################################################################################################
add-type @"
using System;
using System.Runtime.InteropServices;
public class Tricks {
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
@Jaykul
Jaykul / Get-ParameterValue.ps1
Last active January 25, 2021 08:09
Like PSBoundParameters, but including default values
function Get-ParameterValue {
#.Synopsis
# Get the actual values of parameters which have manually set (non-null) default values or values passed in the call
#.Description
# Unlike $PSBoundParameters, the hashtable returned from Get-ParameterValues includes non-empty default parameter values.
# NOTE: Default values that are the same as the implied values are ignored (e.g.: empty strings, zero numbers, nulls).
#.Example
# function Test-Parameters {
# [CmdletBinding()]
# param(
; ----------------------------------------------------------------------------------------------------------------------
; Name ..........: TrayIcon library
; Description ...: Provide some useful functions to deal with Tray icons.
; AHK Version ...: AHK_L 1.1.13.01 x32/64 Unicode
; Original Author: Sean (http://goo.gl/dh0xIX) (http://www.autohotkey.com/forum/viewtopic.php?t=17314)
; Update Author .: Cyruz (http://ciroprincipe.info) (http://ahkscript.org/boards/viewtopic.php?f=6&t=1229)
; Mod Author ....: Fanatic Guru
; License .......: WTFPL - http://www.wtfpl.net/txt/copying/
; Version Date...: 2014 - 01 - 16
; Note ..........: Many people have updated Sean's original work including me but Cyruz's version seemed the most straight
@Jaykul
Jaykul / Add-Parameter.ps1
Last active March 13, 2018 00:41
Dynamic Parameters Made Easier
function Add-Parameter {
[CmdletBinding()]
param(
[Parameter(Position = 0)]
[Management.Automation.RuntimeDefinedParameterDictionary]
$Dictionary = @{},
[Parameter(Position = 1, Mandatory, ValueFromPipeline)]
[Management.Automation.RuntimeDefinedParameter]$Parameter
)
@Jaykul
Jaykul / Convert-CodeCoverage.ps1
Last active June 11, 2018 07:11
How we "compile" modules from source .ps1 files
function Convert-CodeCoverage {
<#
.SYNOPSIS
Convert the file name and line numbers from Pester code coverage of "optimized" modules to the source
.EXAMPLE
Invoke-Pester .\Tests -CodeCoverage (Get-ChildItem .\Output -Filter *.psm1).FullName -PassThru |
Convert-CodeCoverage -SourceRoot .\Source -Relative
Runs pester tests from a "Tests" subfolder against an optimized module in the "Output" folder,
piping the results through Convert-CodeCoverage to render the code coverage misses with the source paths.
@Jaykul
Jaykul / Out-HtmlTable.ps1
Last active October 1, 2022 14:52
Grasping at Formatting Straws
function Out-HtmlTable {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
$InputObject
)
begin {
$Buffer = [System.Collections.ArrayList]::new()
if($InputObject) {