Skip to content

Instantly share code, notes, and snippets.

View gravejester's full-sized avatar

Øyvind Kallstad gravejester

View GitHub Profile
$a -foobar $b # should not match
Invoke-Something -foobar
Invoke-Something -foobar value
Invoke-Something -foobar:$true
Invoke-Something -foobar: $true
Invoke-Something -p1 v1 -p2 10 -p3 'value' -switch -verbose
Invoke-Something -p1 {Get-Something}
Get-Something -p1 'Input' | Invoke-Something -p1 @('one','two','three') | ForEach-Object {$_}
Invoke-Something -parameter1 'value' `
-parameter2 10 `
$adPath = 'OU=Users,OU=Dev,DC=test,DC=local'
$adDomain = 'test.local'
$userPassword = 'aV3ryl0ng-and.securePASSWORD!!'
$users = Get-RandomUser -Amount 30 -Nationality gb,uk -ExcludeFields picture | Select-Object -ExpandProperty results
foreach ($user in $users) {
$newUserProperties = @{
Name = "$($user.name.first) $($user.name.last)"
GivenName = $user.name.first
function Get-RandomUser {
<#
.SYNOPSIS
Generate random user data.
.DESCRIPTION
This function uses the free API for generating random user data from https://randomuser.me/
.EXAMPLE
Get-RandomUser 10
.EXAMPLE
Get-RandomUser -Amount 25 -Nationality us,gb -Format csv -ExludeFields picture
# testing psInlineProgress
$null = Start-Transcript -Path C:\users\grave\Scripts\InlineProgressBar\transcript.txt
Write-Host ''
# Simple progressBar
Write-Host 'Example of default behaviour' -ForegroundColor Magenta
Write-Host ''
$collection = 0..12
$count = 0
function New-DummyFile {
<#
.SYNOPSIS
Create dummy file(s).
.DESCRIPTION
Quickly create a set of dummy files, with completely randomized names,
size and folder structure.
.EXAMPLE
'C:\Demo' | New-DummyFile -Files 10 -min 1kb -max 10kb
.EXAMPLE
function Invoke-PathShortener {
<#
.SYNOPSIS
Path Shortener
.NOTES
Author: Øyvind Kallstad
Date: 05.04.2016
Version: 2
#>
[CmdletBinding()]
function Get-PackageUpdate {
[CmdletBinding()]
param (
[Parameter()]
[string] $Name,
[Parameter()]
[string] $ProviderName
)
param([Parameter(Position = 0)][string] $Path = 'C:\Users\grave\Downloads\ChessData-master\')
$code = @{
Name = 'ResultCounter'
Namespace = 'ChessData'
PassThru = $true
UsingNamespace = @(
'System.Collections.Concurrent',
'System.IO',
'System.Threading.Tasks'
)
function ConvertTo-Digits {
<#
.SYNOPSIS
Convert an integer into an array of bytes of its individual digits.
.DESCRIPTION
Convert an integer into an array of bytes of its individual digits.
.EXAMPLE
ConvertTo-Digits 145
.INPUTS
System.UInt64
function Get-LuhnChecksum {
<#
.SYNOPSIS
Calculate the Luhn checksum of a number.
.DESCRIPTION
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm,
is a simple checksum formula used to validate a variety of identification numbers, such as
credit card numbers, IMEI numbers, National Provider Identifier numbers in the US, and
Canadian Social Insurance Numbers. It was created by IBM scientist Hans Peter Luhn.
.EXAMPLE