Skip to content

Instantly share code, notes, and snippets.

param (
[Parameter(Mandatory=$True)]
[System.Array]$StringList,
[Parameter(Mandatory=$False)]
[System.Array]$Delimiter = '.'
)
$StringListReversed = @()
foreach ($String in $StringList) {
$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

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.
@exchange12rocks
exchange12rocks / dynamic-fixed-nested-vhdx.ps1
Last active November 25, 2020 19:36
Dynamic VHDX is smaller than used space inside it
$VHDDesc = @{
Dynamic = @{
Letter = 'Z'
Size = 100GB
Path = 'B:\Temp\Dynamic'
}
Fixed = @{
Letter = 'Y'
Size = 70GB
}
# 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
# https://blogs.msdn.microsoft.com/wmi/2009/07/27/scripting-wmi-namespace-security-part-3-of-3/
Param (
[parameter(Mandatory=$true,Position=0)][string] $namespace,