Skip to content

Instantly share code, notes, and snippets.

@madrum
madrum / public-ps-cheat-sheet
Created September 8, 2022 15:13
PowerShell cheat sheet (Public)
[TOC]
---
- [PowerShell cheatsheet](#powershell-cheatsheet)
- [Code Formatting](#code-formatting)
- [Search command history](#search-command-history)
- [Requirement](#requirement)
- [Function](#function)
- [Parameters](#parameters)
- [ShouldProcess and ShouldContinue](#shouldprocess-and-shouldcontinue)
- [Arrays and Hashtables](#arrays-and-hashtables)
@madrum
madrum / Convert-ObjectTo2DHashtable.ps1
Last active March 12, 2022 23:03
Convert Object to 2D Hashtable
<#
.DESCRIPTION
Convert object to 2-dimensional object [Hashtable] with property path and value
.LINK
Source: https://stackoverflow.com/a/63152660/4582288
#>
# function ConvertTo-2DObject {
[CmdletBinding()]
@madrum
madrum / sql-stuff.md
Last active December 23, 2021 19:10
sql-stuff

SQL stuff

-- query execution time from DMVs: https://dba.stackexchange.com/questions/232707/collect-sql-server-query-execution-time-in-seconds
SELECT TOP 50
st.text,
SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,  
    ((CASE statement_end_offset   
        WHEN -1 THEN DATALENGTH(st.text)  
        ELSE qs.statement_end_offset