Skip to content

Instantly share code, notes, and snippets.

View thedavecarroll's full-sized avatar
🧑‍💻
Clever Status

Dave Carroll thedavecarroll

🧑‍💻
Clever Status
View GitHub Profile
@stevenkuhn
stevenkuhn / gist:5062660
Last active March 7, 2023 16:03
This PowerShell script generates release notes for Octopus Deploy that contain the GitHub commits and JIRA issues from the current build to the latest production release. It will also create the Octopus release based on the TeamCity build number.
#
# Assumptions
#
# 1. If you have a Octopus release deployed, say 1.0.0.73, there is a git
# tag set for that commit in GitHub that is "v1.0.0.73".
#
# 2. You have TeamCity label each successful build in GitHub with the format
# "v{build number}. Sidenote: it appears that TeamCity only labels the
# default branch, but not feature branches.
#
@AndySchneiderDev-zz
AndySchneiderDev-zz / Update-Schema.ps1
Last active June 19, 2018 18:55
PowerShell to Udpate Active Directory Schema
# This should only be used in a development environment and is for demonstration purposes only
# Use at your own risk
# This adds an attribute to the user class
# Written by Andy Schneider, http://get-powershell.com
Function New-OID {
$Prefix="1.2.840.113556.1.8000.2554"
$GUID=[System.Guid]::NewGuid().ToString()
$Parts=@()
$Parts+=[UInt64]::Parse($guid.SubString(0,4),"AllowHexSpecifier")
@jdhitsolutions
jdhitsolutions / SendTo-Gist.ps1
Last active November 13, 2020 18:06
A PowerShell ISE script to send selected text as a Github gist. This requires my New-GitHubGist function.
#requires -version 4.0
#dot source the script with the New-GitHubGist function
. C:\scripts\New-GitHubGist.ps1
Function SendTo-Gist {
[cmdletbinding()]
Param(
[Parameter(Position = 0)]
[ValidateNotNullorEmpty()]
@jdhitsolutions
jdhitsolutions / New-GithubGist.ps1
Last active March 16, 2023 11:53
A PowerShell script to create a new gist on Github.
#requires -version 4.0
Function New-GitHubGist {
[cmdletbinding(SupportsShouldProcess,DefaultParameterSetName = "Content")]
Param(
[Parameter(Position = 0, Mandatory, HelpMessage = "What is the name for your gist?",ValueFromPipelineByPropertyName)]
[ValidateNotNullorEmpty()]
[string]$Name,
@Jaykul
Jaykul / ValidateUnique.md
Last active May 7, 2022 01:13
Validating PowerShell class properties

The simplest way to enforce rules on PowerShell class properties is to set the Type of the property, of course. But sometimes you want something a little bit more clever than that. One solution is to use a Validate* attribute, like ValidateRange or ValidateLength or ValidateSet attribute...

However, you can write your own, by just deriving from ValidateArguments() or something that derives from that, like the ValidateEnumeratedArguments class allows you to validate a whole array of items.

For instance, a simple validator would be one that validates uniqueness, based on a specific property. Our validator will be created fresh each time it's used, and then each item in the array will be passed through ValidateElement, so this works:

using namespace System.Collections.Generic
usin

Credit: Mark Kraus
Website: https://get-powershellblog.blogspot.com

Collection Type Guidence

When to use what

  • Use Arrays if you know the element types and have a fixed length and/or known-up-front collection size that will not change.
  • Use ArrayList if you have an unkown collection size with either unknown or mixed type elements.
  • Use a Generic List when know the type of the elements but not the size of the collection.
  • Use a HashTable if you are going to do key based lookups on a collection and don't know the object type of the elements.
  • Use a Dictionary<TKey, TValue> you are going to do key based lookups on a collection and you know the type of the elements.
  • Use a HashSet when you know the type of elements and just want unique values and quick lookups and assignmnets.
@mklement0
mklement0 / Time-Command.ps1
Last active December 18, 2024 07:42
PowerShell function that times the execution of one or more commands, averaged over a specifiable number of runs.
<#
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/9e1f13978620b09ab2d15da5535d1b27/raw/Time-Command.ps1 | iex
@potatoqualitee
potatoqualitee / mentalhealth.txt
Last active November 7, 2024 15:33
⛔ BlueSky mental health mute list
# mute here: https://bsky.app/moderation
election
president-elect
hurricane
storm surge
climate crisis
Iran
Israel
ballistic missiles
North Korea
$crypto = @"
P k T r 2 s z 2 * c F -
r a z 7 G u D 4 w 6 U #
g c t K 3 E @ B t 1 a Y
Q P i c % 7 0 5 Z v A e
W 6 j e P R f p m I ) H
y ^ L o o w C n b J d O
S i 9 M b e r # ) i e U
* f 2 Z 6 M S h 7 V u D
5 a ( h s v 8 e l 1 o W
@Jaykul
Jaykul / ToDictionary.ps1
Created October 21, 2019 22:54
More LINQ Helpers for PowerShell
# Add a .ToDictionary(KeyType,ValueType) for all hashtables
Update-TypeData -TypeName Hashtable -MemberType ScriptMethod -MemberName ToDictionary -Value {
param([Type]$KeyType,[Type]$ValueType)
[Scriptblock]::Create(
"[Enumerable]::ToDictionary(
[DictionaryEntry[]]@(`$this.GetEnumerator()),
[Func[DictionaryEntry,$($KeyType.FullName)]]{ `$args.Key },
[Func[DictionaryEntry,$($ValueType.FullName)]]{ `$args.Value })"
).Invoke()
}