Skip to content

Instantly share code, notes, and snippets.

function Get-NumberRange
{
[cmdletbinding()]
Param()
DynamicParam {
$Dictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
$NewDynParam = @{
Name = "Firstnumber"
Alias = "int"
[cmdletbinding()]
Param(
[string]$ServiceName = "Bonjour Service"
)
$f = $MyInvocation.InvocationName | Split-Path -Leaf
Write-Verbose -Message "$f - START"
$cimService = Get-CimInstance -Query "Select * from win32_Service where Name='$ServiceName'" -ErrorAction SilentlyContinue
function Get-SingleWeekDate
{
<#
.Synopsis
Get all dates for a specific day of the week on year forward. Please give me a better function name!!
.DESCRIPTION
Long description which is very short
.EXAMPLE
Get-SingleWeekDate -DayOfWeek Monday
$GetEventLog = @{
After = Get-Date -Date "22.08.2016"
LogName = "System"
EntryType = "Information"
InstanceId = 6006
}
$GetEventLog.Add("Before",$GetEventLog.After.Adddays(5))
$csvObjects = foreach($int in (0..10000))
{
$date = get-date
[pscustomobject]@{
id = (10000+$int)
Msg = "this belongs to id $int"
Date = $date.AddDays(2000-$int)
Random = get-random
ticks = $date.Ticks
}
$measureWhere = @()
foreach ($count in (0..10))
{
$id1 = $CollectionOfIDs | Get-Random
$id2 = $CollectionOfIDs | Get-Random
[gc]::Collect()
$measureWhere += Measure-Command -Expression {
$csvObjects.Where({$_.id -eq $id1 -or $_.id -eq $id2})
}
}
$csvHash = @{}
foreach($obj in $csvObjects)
{
$csvHash[$obj.id] = $obj
}
foreach($count in (0..10))
{
$id1 = $CollectionOfIDs | Get-Random
$id2 = $CollectionOfIDs | Get-Random
[gc]::Collect()
$measureHash += Measure-Command -Expression {
$csvHash[$id1,$id2]
}
}
$Source = @”
using System;
namespace ArrayTest
{
public static class ArrayStuff
{
public static sample ForEach(System.Array _items, int[] Id)
{
foreach (sample item in _items)
function Test-String
{
param(
[parameter(Valuefrompipeline)]
[string]$InputObject
)
Begin
{}