Skip to content

Instantly share code, notes, and snippets.

View cdhunt's full-sized avatar

Chris Hunt cdhunt

View GitHub Profile
# Requires -Module NameIt, Humanizer
function New-Password {
[CmdletBinding(DefaultParameterSetName = 'Random')]
param (
[Parameter(ParameterSetName = 'Random')]
[switch]
$Random,
[Parameter(ParameterSetName = 'Random')]
[switch]
@cdhunt
cdhunt / configuration.dsc.yaml
Created December 28, 2023 15:00
winget configuration
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
# Reference: https://github.com/dotnet/aspnetcore/blob/main/docs/BuildFromSource.md
properties:
resources:
- resource: Microsoft.WinGet.DSC/WinGetPackage
directives:
description: Install PowerShell 7
allowPrerelease: true
settings:
id: Microsoft.PowerShell
@cdhunt
cdhunt / Get-CredentialFromWindowsCredentialManager.ps1
Last active June 1, 2023 23:48 — forked from toburger/Get-CredentialFromWindowsCredentialManager.ps1
Gets a PowerShell Credential [PSCredential] from the Windows Credential Manager. This only works for Generic Credentials.
<#
.SYNOPSIS
Gets a PowerShell Credential (PSCredential) from the Windows Credential Manager
.DESCRIPTION
This module will return a [PSCredential] object from a credential stored in Windows Credential Manager. The
Get-StoredCredential function can only access Generic Credentials.
Alias: GSC
@cdhunt
cdhunt / Convert-Base64.ps1
Last active March 17, 2023 18:36
A PowerShell function to duplicated the Unix base64 util.
function Convert-Base64 {
[CmdletBinding()]
[Alias("base64")]
param (
[Parameter(Mandatory, Position = 0, ValueFromPipeline)]
[string]
$InputObject,
[Parameter()]
[switch]
@cdhunt
cdhunt / DaggerSdk.cs
Created November 11, 2022 12:10
Generated Types from Dagger GraphQL Schema
// <auto-generated> This file has been auto generated. </auto-generated>
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
@cdhunt
cdhunt / night-owl.chunt.omp.json
Last active August 30, 2022 13:04
oh-my-posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#26C6DA",
"foreground": "#011627",
"leading_diamond": "\u256d\u2500\ue0b6",
@cdhunt
cdhunt / .ohmyposh-lite.json
Last active August 5, 2022 17:08
oh-my-posh theme
{
"console_title": true,
"blocks": [
{
"type": "newline"
},
{
"type": "prompt",
"alignment": "left",
"segments": [
@cdhunt
cdhunt / Install.WinGet.ps1
Created August 5, 2022 12:39
This will grab the WinGet appx file and two dependencies and install without user interaction.
function Install-WinGet() {
Write-Information "[winget] Downloading Appx packages"
Push-Location $env:TEMP
# https://github.com/microsoft/winget-cli/issues/2230
if (-not (Test-Path 'Microsoft.DesktopAppInstaller.msixbundle')) {
Write-Information "`tMicrosoft.DesktopAppInstaller"
Invoke-WebRequest 'https://aka.ms/getwinget' -OutFile 'Microsoft.DesktopAppInstaller.msixbundle' -UseBasicParsing
@cdhunt
cdhunt / map_fold.ps1
Created October 27, 2016 13:55
Map and Fold implementations in Powershell
function map([scriptblock]$map, [Collections.IEnumerable]$x, $y) { $x.ForEach({& $map $_ $y}) }
# Two parameters
map { param($x, $y) $x + $y } @(1,2,3) 10
# Anonymous function as a value
$squareIt = { param($x) $x + $x }
map $squareIt @(1,2,3)
# One parameter
# I don't want to install Python so this docker image and Pwsh function mimic a binary
<# Dockerfile
FROM python:3-alpine
RUN pip install --upgrade cloudsmith-cli
WORKDIR /working
ENTRYPOINT ["cloudsmith"]
#>
function cloudsmith {