Skip to content

Instantly share code, notes, and snippets.

View cdhunt's full-sized avatar

Chris Hunt cdhunt

View GitHub Profile
function New-PSRepositoryRequirement {
param (
[string]$Name,
[string]$Uri,
[string]$Policy = 'Trusted'
)
New-RequirementGroup 'Repository' -ScriptBlock {
@{
Describe = "$Name is registered"
Test = {
Emery Mora
Yasmine Burke
Justine Beard
Pedro Hardy
Aryana Knox
Gavyn Shaffer
Matilda Meadows
Emilio Kennedy
Nicholas Mays
Quinton Larsen
@cdhunt
cdhunt / Get-Service.ps1
Last active March 25, 2020 21:03
A Linux implementation of Get-Service
Function Get-Service {
[CmdletBinding()]
Param(
[Parameter( Position = 0, ValueFromPipeline = $True )][String]$Name
)
Begin {
# Stop Function if Not Linux
If ( -Not $IsLinux ) {
#requires -Module NameIt
while ($true) {
$tc = Get-Random -Minimum 1 -Maximum 15
$t = 0
$c=ig "[noun]"
Write-Host "`t Context $c" -ForegroundColor Green
@cdhunt
cdhunt / downloadsgenerator.ps1
Last active January 23, 2018 20:18
Download Simulator
#requires -Module NameIt
while ($true) {
$limit = Get-Random -Minimum 500 -Maximum 4000
$t = 0
$p = 0
$r=ig "[adjective]-[noun]_v#.#.##."
$r += @('zip', 'exe', '7zip') | Get-Random
while($p -lt 100) {
@cdhunt
cdhunt / snapdrive.psm1
Created September 27, 2017 12:19
NetApp Windows Unified Host Utilities DSC Resource
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[System.String]
$Path,
function ArchitestVolumeHaveSizeRemaining([Microsoft.Management.Infrastructure.CimInstance]$ActualValue, $ExpectedValue, [switch] $Negate)
{
$ActualValuePropertyValue = $ActualValue | Select-Object -ExpandProperty SizeRemaining
[bool] $succeeded = $ActualValuePropertyValue -gt $ExpectedValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
@cdhunt
cdhunt / .hyper.js
Last active March 16, 2017 15:01
Hyper config
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 14,
// font family with optional fallbacks
fontFamily: '"Fira Code", monospace',
uiFontFamily: '"Fira Code", monospace',
@cdhunt
cdhunt / Maybe.ps1
Last active January 10, 2017 21:38
Messing around with a filter function that is a mashup of Where-Object and If/Then. It might be a solution looking for a problem, but it's also fairly versatile. Do you see any value in it?
function Where-ObjectMaybe
{
[CmdletBinding(DefaultParameterSetName='Just')]
[Alias('Maybe')]
Param
(
[Parameter(ValueFromPipeline=$true,
Position=4)]
$InputObject,
@cdhunt
cdhunt / attr.ps1
Created January 3, 2017 18:45
Example usage of Custom Attributes
. "$PSScriptRoot\attr_common.ps1"
class PowerShellExecutable : Executable
{
[ExecutableArgument('File')]
[string]$File
[ExecutableArgument('Password', $true)]
[string]$Password