Skip to content

Instantly share code, notes, and snippets.

Kirill Nikolaev exchange12rocks

Block or report user

Report or block exchange12rocks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Credit: Mark Kraus

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.
View Set-WmiNamespaceSecurity.ps1
# Copyright (c) Microsoft Corporation. All rights reserved.
# For personal use only. Provided AS IS and WITH ALL FAULTS.
# Set-WmiNamespaceSecurity.ps1
# Example: Set-WmiNamespaceSecurity root/cimv2 add steve Enable,RemoteAccess
Param (
[parameter(Mandatory=$true,Position=0)][string] $namespace,
View Execute-LimitedNumberOfPSJobs.ps1
$maxConcurrentJobs = 100 #Max. number of simultaneously running jobs
foreach($Object in $Objects) { #Where $Objects is a collection of objects to process. It may be a computers list, for example.
$Check = $false #Variable to allow endless looping until the number of running jobs will be less than $maxConcurrentJobs.
while ($Check -eq $false) {
if ((Get-Job -State 'Running').Count -lt $maxConcurrentJobs) {
$ScriptBlock = {
#Insert the code of your workload here
Start-Job -ScriptBlock $ScriptBlock
View Reverse-DelimitedString.ps1
param (
[System.Array]$Delimiter = '.'
$StringListReversed = @()
foreach ($String in $StringList) {
You can’t perform that action at this time.