Skip to content

Instantly share code, notes, and snippets.

View brianbunke's full-sized avatar

Brian Bunke brianbunke

View GitHub Profile
# 2019-03-01
# Whatcom IT Professionals meetup
# https://www.meetup.com/Whatcom-IT-Professionals/events/259166239/
# Why and How to Get Started With Automated Documentation
function Get-TheComputerThings ([switch]$Again) {
[PSCustomObject]@{
Name = 'LTAlpha'
OS = 'Windows 10 Enterprise'
@brianbunke
brianbunke / VMware65RestAPI.ps1
Last active August 12, 2021 06:49
Learning the vSphere 6.5 REST API
# vSphere 6.5 VCSA - REST API testing
$vCenterName = 'YOURNAMEHERE'
$BaseURI = "https://$vCenterName/rest"
# At first, I could only make this work with vSphere SSO credentials
# Try that if AD auth is throwing 401 Unauthorized errors at you
# (Discovered later that it didn't like the colon in my AD user's password)
# Can also try "https://YOURVCENTER/apiexplorer" in your browser to test login creds
$c = Get-Credential -UserName 'administrator@vsphere.local' -Message 'Enter password'
@brianbunke
brianbunke / AoC2017warmup.ps1
Last active November 29, 2017 04:55
AoC 2017 warm-up
# Advent Of Code 2017 warm-up challenge
# https://twitter.com/_sorceress/status/935256907408867328
# https://pastebin.com/BMd61PUv
# @brianbunke, 2017/11/27
# Get raw content
$1 = (Invoke-WebRequest https://pastebin.com/raw/wGmzZHeq).Content
# Split the instruction set on the comma/space combination
$ParsedInput = $1 -split ', '
@brianbunke
brianbunke / Power-State.Vester.ps1
Created March 9, 2017 07:01
Example of a new Vester test, as of version 1.0.1
# Test file for the Vester module - https://github.com/WahlNetwork/Vester
# Called via Invoke-Pester VesterTemplate.Tests.ps1
# Test title, e.g. 'DNS Servers'
$Title = 'Power State'
# Test description: How New-VesterConfig explains this value to the user
$Description = 'Starts or stops VMs'
# The config entry stating the desired values
#Requires -Version 3
Import-Module VMware.VimAutomation.Core
Connect-VIServer XXXXX
$Report = New-Object 'System.Collections.Generic.List[PSCustomObject]'
$VM = Get-VM
$VM | ForEach-Object {
$Obj = [PSCustomObject][ordered]@{
VMName = $_.Name
@brianbunke
brianbunke / Mock-VM-Attempt2.ps1
Created January 15, 2017 18:41
Mock a PowerCLI VM object
# Barely working :D
# Follows my previous Gist, https://gist.github.com/brianbunke/13e32ae67a9232d2224601e937eebba7
# http://theshellnut.com/exploring-powercli-types/
# http://stackoverflow.com/questions/14141043/resolving-an-ambiguous-reference
ipmo VMware.VimAutomation.Core
$r = "c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Sdk\VMware.VimAutomation.Sdk.Types.dll",
"c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Core\VMware.VimAutomation.ViCore.Types.dll",
@brianbunke
brianbunke / Mock-VM-Attempt1.ps1
Last active January 13, 2017 23:48
Trying to figure out how to mock a PowerCLI VM object
# This code doesn't work. :) Soliciting feedback
# Just started duplicating info from here:
# (Get-VM 'ExampleVM') | gm | Where MemberType -eq 'Property' | Select Name,Definition
$r = "c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Sdk\VMware.VimAutomation.Sdk.Types.dll",
"c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Core\VMware.VimAutomation.ViCore.Types.dll"
Add-Type -ReferencedAssemblies $r -TypeDefinition "
using VMware.VimAutomation.ViCore.Types.V1;
@brianbunke
brianbunke / Update-ScriptFileInfo-2017Jan.ps1
Last active March 19, 2021 00:58
Using "Update-ScriptFileInfo" properly in January 2017
$Splatting = @{
Path = "$env:USERPROFILE\Desktop\Your-Script.ps1"
Version = '1.0.0' # http://semver.org ;)
# GUID will randomly auto-generate for new scripts
# Only specify GUID if you're going to overwrite existing properties on an updated script version
Author = 'YourPSGalleryUsername'
Description = 'Explain your script to prospective users, preferably in one sentence.'
# CompanyName
# Copyright
Tags = @('super','awesome','radical')
@brianbunke
brianbunke / Draft1-Measure-LastCommand.ps1
Created January 7, 2017 07:28
Illustrating the initial effects of "Update-ScriptFileInfo -Force"
<#PSScriptInfo
.VERSION 1.0
.GUID a9323abc-0567-4c4f-ad8e-cdd4cb236e3a
.AUTHOR Brian
.COMPANYNAME
@brianbunke
brianbunke / Get-Diacritic.ps1
Created March 7, 2016 02:43
PSGames-201603-Advanced
function Get-Diacritic {
<#
.SYNOPSIS
Find filenames with diacritic marks, export the list to CSV, and email the list to your boss.
.LINK
http://powershell.org/wp/2016/03/05/2016-march-scripting-games-puzzle/
#>
[CmdletBinding()]
param (