Skip to content

Instantly share code, notes, and snippets.

View AspenForester's full-sized avatar

JB Lewis AspenForester

  • Hennepin County, MN, USA
  • Minnesota, USA
View GitHub Profile
@jdhitsolutions
jdhitsolutions / Make-Module.ps1
Last active March 10, 2022 02:42
My module generation code from my Chicago PowerShell presentation on July 31, 2020.
#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.
@sheldonhull
sheldonhull / measure-powershell-objects.ps1
Created July 13, 2020 19:48
[Aggregate PowerShell Objects] How to use measuring and grouping to calculate the group counts of a powershell object. This can be useful for preaggregation of totals before exporting to excel for example #powershell
$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 = $_
@brantb
brantb / Manifest.Tests.ps1
Last active October 17, 2017 17:54
Pester test suite for module manifest
$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
}
@Jaykul
Jaykul / Convert-CodeCoverage.ps1
Last active June 11, 2018 07:11
How we "compile" modules from source .ps1 files
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.
@Jaykul
Jaykul / PowerShellGet.psm1
Last active December 15, 2020 08:12
PowerShell Gallery Module - Light
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 (
@dfinke
dfinke / Get-Snoverism.ps1
Created December 8, 2015 20:06
Wisdom form the Shellfather, Jeffrey Snover - via Don Jones
function Get-Snoverism {
(Invoke-WebRequest http://snoverisms.com/).images.src |
Where {$_ -match 'quotes'} |
Get-Random |
Where { start "http://snoverisms.com/$($_)" }
}