Skip to content

Instantly share code, notes, and snippets.

View markekraus's full-sized avatar
😀

Mark Kraus markekraus

😀
View GitHub Profile
@vexx32
vexx32 / Get-Age.ps1
Last active June 20, 2020 03:53
for Mark Kraus ♥
function Get-Age {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidateScript(
{
$_ -lt [datetimeoffset]::UtcNow
}
)]
[datetimeoffset]

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.
@indented-automation
indented-automation / Update-PesterTest.ps1
Last active October 4, 2021 18:17
Migrating to Pester 4.0.7
function Update-PesterTest {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Alias('FullName')]
[String]$Path
)
begin {
$shouldParams = [String[]](Get-Command Should).Parameters.Keys