This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertTo-GUID { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Position = 0, ValueFromPipeline = $true)] | |
[string] $ImmutableId | |
) | |
try { | |
$byteArray = [Convert]::FromBase64String($ImmutableId) | |
$newGuid = [Guid]::new($byteArray) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertTo-ImmutableId { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Position = 0, ValuefromPipeline = $true, ValueFromPipelinebyPropertyName = $true)] | |
[Guid]$ObjectGUID | |
) | |
try { | |
$byteArray = $ObjectGUID.ToByteArray() | |
$immutableId = [Convert]::ToBase64String($byteArray) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ObjectPropertyInfo { | |
#Requires -Version 3 | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true, Position = 0)] | |
$InputObject | |
) | |
$objectProperties = $InputObject | Get-Member -MemberType '*Property*' | |
Write-Verbose -Message "Object have $($objectProperties.Count) properties." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-GeoLocation { | |
<# | |
.SYNOPSIS | |
Get current location. | |
.DESCRIPTION | |
This function tries to get the latitude and longitude coordinates of the current location, | |
and will look up those coordinates on OpenStreetMap to get address information. | |
.EXAMPLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-DPMActiveOwner { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[ValidateNotNullOrEmpty()] | |
[string[]] $Path | |
) | |
PROCESS { | |
foreach ($thisPath in $Path) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |