This file contains 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
#requires -version 5.1 | |
#requires -module PowerShellGet | |
<# | |
The function assumes you have git installed and use it for source control | |
This code contains hard-coded references for my environment. This file | |
is offered as educational and reference material. It will not run for you | |
without revision. |
This file contains 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
$Companies = @( | |
[pscustomobject]@{CompanyName = 'Foo'; UserCount = 5 } | |
[pscustomobject]@{CompanyName = 'Foo1'; UserCount = 5 } | |
[pscustomobject]@{CompanyName = 'Foo'; UserCount = 2 } | |
[pscustomobject]@{CompanyName = 'Foo'; UserCount = 3 } | |
) | |
$CalculatedResults = $Companies | Group-Object CompanyName | ForEach-Object { | |
$i = $_ |
This file contains 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
$ModuleManifestName = 'MyModuleName.psd1' | |
$ModuleManifestPath = "$PSScriptRoot\..\$ModuleManifestName" | |
Describe 'Module Manifest Tests' { | |
# Test-ModuleManifest is slooooooow for some reason :( | |
It 'Passes Test-ModuleManifest' -Skip { | |
Test-ModuleManifest -Path $ModuleManifestPath | |
$? | Should Be $true | |
} |
This file contains 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 Convert-CodeCoverage { | |
<# | |
.SYNOPSIS | |
Convert the file name and line numbers from Pester code coverage of "optimized" modules to the source | |
.EXAMPLE | |
Invoke-Pester .\Tests -CodeCoverage (Get-ChildItem .\Output -Filter *.psm1).FullName -PassThru | | |
Convert-CodeCoverage -SourceRoot .\Source -Relative | |
Runs pester tests from a "Tests" subfolder against an optimized module in the "Output" folder, | |
piping the results through Convert-CodeCoverage to render the code coverage misses with the source paths. |
This file contains 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 Find-Module { | |
<# | |
.Synopsis | |
A wrapper for Invoke-RestMethod to search the PowerShell Gallery | |
.Description | |
In order to support wildcards, we build pretty complicated URLs, | |
and then we filter the results by title | |
#> | |
[CmdletBinding()] | |
param ( |
This file contains 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-Snoverism { | |
(Invoke-WebRequest http://snoverisms.com/).images.src | | |
Where {$_ -match 'quotes'} | | |
Get-Random | | |
Where { start "http://snoverisms.com/$($_)" } | |
} |