Skip to content

Instantly share code, notes, and snippets.

View schittli's full-sized avatar

Tom-- schittli

  • Biel / Bienne, Switzerland
  • 13:08 (UTC +02:00)
View GitHub Profile
@Jaykul
Jaykul / Write-Information.ps1
Created January 21, 2017 08:00
A wrapper to improve Write-Information
using namespace System.Management.Automation
function Write-Information {
<#
.Synopsis
An enhancement to the built-in Write-Information to make it show the calling script line
.Description
Creates a stopwatch that tracks the time elapsed while a script runs, and adds caller position and time to the output
.Example
@Jaykul
Jaykul / RsaKeyStore.psm1
Last active April 14, 2022 04:55
Working with RSA MachineKeys
using namespace System.Security.Principal
using namespace System.Security.Cryptography
using namespace System.Security.AccessControl
using namespace System.Security.AccessControl.AccessRule
Set-Variable -Scope Script -Name RSA_KEY_LENGTH -Value 2048 -Option Constant -ErrorAction SilentlyContinue
function Add-RsaKey
{
[CmdletBinding()]
@Jaykul
Jaykul / UnderscoreNotAllowedInFunctionName.psm1
Created January 11, 2017 21:46
Custom PSScriptAnalyzer Rules
<#
.SYNOPSIS
Do not use underscores in command names
.DESCRIPTION
You should not use underscores in PowerShell command names
To fix a violation of this rule, rename your command to remove underscores.
.EXAMPLE
Measure-UnderscoreNotAllowedInFunctionName -ScriptBlockAst $ScriptBlockAst
.INPUTS
[System.Management.Automation.Language.ScriptBlockAst]
@Jaykul
Jaykul / Module.psd1
Last active March 13, 2018 00:30
PowerShell 5.0 Module Loading Bug
@{
ModuleVersion = '16.12.1.1'
# QMODHelper is a meta module that exists to depend upon all the Questionmark modules, but ...
# RequiredModules are limited/broken in PS 5.x so we work around it by importing in a RootModule
RootModule = 'Module.psm1'
RequiredModules = @()
<#
RequiredModules = @(
# Microsoft modules which are required (at least the first two are required just to parse the module files)
@christianrondeau
christianrondeau / AutoKeyboardLayout.ahk
Last active May 11, 2023 19:50
Automatic keyboard layout change on window focus using AutoHotkey
; How to use:
; 1. Install AuthotKey: https://www.autohotkey.com
; 2. Save this script in `My Documents`
; 3. Create a shortcut in the Startup folder (`Win`+`R`, `shell:startup`)
; 4. Change the configurations below
; 5. Start and test the script!
; Configuration
; Cultures can be fetched from here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx
@Espionage724
Espionage724 / remove.cmd
Last active February 18, 2025 11:03
install_wim_tweak Remove
install_wim_tweak.exe /o /c "Microsoft-Windows-Internet" /r
install_wim_tweak.exe /o /c "Adobe-Flash" /r
install_wim_tweak.exe /o /c "Microsoft-Windows-Cortana" /r
install_wim_tweak.exe /o /c "Microsoft-Windows-Search2" /r
install_wim_tweak.exe /o /c "Microsoft-Windows-SearchEngine" /r
install_wim_tweak.exe /o /c "Microsoft-Windows-RetailDemo" /r
install_wim_tweak.exe /o /c "Microsoft-Windows-ContactSupport" /r
install_wim_tweak.exe /o /c "Microsoft-PPIProjection" /r
install_wim_tweak.exe /o /c "Microsoft-Windows-Backup" /r
install_wim_tweak.exe /o /c "Windows-Defender" /r
@Jaykul
Jaykul / Enable-FileSharing.ps1
Last active March 13, 2018 00:27
Enable File and Printer Sharing (or any other firewall group) on the Domain profile (only).
#Requires -Version 5.0
#Requires -Module NetSecurity
param(
$DisplayGroup = "File and Printer Sharing",
[Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetSecurity.Profile]$NetworkProfile = "Domain"
)
foreach($rule in Get-NetFirewallRule -DisplayGroup $DisplayGroup) {
@Jaykul
Jaykul / WhatIsIt.ps1
Created December 19, 2016 05:22
All those informative variables in PowerShell 6.0
$script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction Ignore)) -or $IsWindows
$script:IsLinux = (Get-Variable -Name IsLinux -ErrorAction Ignore) -and $IsLinux
$script:IsOSX = (Get-Variable -Name IsOSX -ErrorAction Ignore) -and $IsOSX
$script:IsCoreCLR = (Get-Variable -Name IsCoreCLR -ErrorAction Ignore) -and $IsCoreCLR
$script:IsNanoServer = $null -ne ('System.Runtime.Loader.AssemblyLoadContext' -as [Type])
$script:IsInbox = $PSHOME.EndsWith('\WindowsPowerShell\v1.0', [System.StringComparison]::OrdinalIgnoreCase)
@leeramsay
leeramsay / PSADT-Cheatsheet.ps1
Last active May 14, 2025 04:34
PSADT snippits/cheatsheet
## Commonly used PSADT env variables
$envCommonDesktop # C:\Users\Public\Desktop
$envCommonStartMenuPrograms # C:\ProgramData\Microsoft\Windows\Start Menu\Programs
$envProgramFiles # C:\Program Files
$envProgramFilesX86 # C:\Program Files (x86)
$envProgramData # c:\ProgramData
$envUserDesktop # c:\Users\{user currently logged in}\Desktop
$envUserStartMenuPrograms # c:\Users\{user currently logged in}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
$envSystemDrive # c:
$envWinDir # c:\windows
@mikoim
mikoim / README.md
Last active March 30, 2025 06:04
[Updated! Aug 14 2020] YouTube recommended encoding settings on ffmpeg (+ libx264)

Parameters

Container: MP4

Parameter YouTube recommends setting
-movflags faststart moov atom at the front of the file (Fast Start)

Video codec: H.264