Skip to content

Instantly share code, notes, and snippets.

View Geogboe's full-sized avatar

geogboe Geogboe

View GitHub Profile
@Geogboe
Geogboe / my_action_plugin.py
Last active November 4, 2022 01:03 — forked from ju2wheels/my_action_plugin.py
Ansible 2.4 Action Plugin Template
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Standard base includes and define this as a metaclass of type
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
# Important contants
from ansible import constants as C
# Common error handlers
@Geogboe
Geogboe / vscode-snippet-copy-paste.ps1
Last active January 5, 2021 17:05
vscode-snippet-copy-paste - Convert Code Block to VSCode Snippet
# 2021 - George Bowen
# Usage:
# Add this to your vscode powershell profile "code $profile",
# then, select any text in your editor, type alt+shift+s, select Convert Code Block to Snippet,
# which will return a json code block for you to add to your vscode snippets file
function ConvertTo-JsonCodeBlock {
<#
.SYNOPSIS
<#
.SYNOPSIS
Installs a given terraform plugin/provider from github
.EXAMPLE
PS C:\> ./Install-TerraformPlugin -GitHubPath Mastercard/terraform-provider-restapi
Install-TerraformPlugin will search github the repo: Mastercard/terraform-provider-restapi
foo and check if the latest version has been added to the local terraform
plugins dir. If not, it will downlaod and install it.
.NOTES
- Only supports Windows at the moment.
@Geogboe
Geogboe / ConvertTo-ArrayList.ps1
Created August 22, 2018 13:06
Converts the properties of a PSCustomObject to an ArrayList
function ConvertTo-ArrayList ( [PSCustomObject]$CustomObject ) {
$ObjectProperties = $CustomObject.PSObject.Properties
$IntermediateHashtable = @{}
foreach ( $Property in $ObjectProperties ) {
$IntermediateHashtable."$($Property.Name)" = $Property.Value
@Geogboe
Geogboe / ConvertTo-BasicAuth.ps1
Last active August 22, 2018 11:54
Function to convert a PSCredential to a Basic Auth encoded credential
function ConvertTo-BasicAuth {
[cmdletbinding()]
param (
[Parameter( ValueFromPipeline )]
[PSCredential]
$Credential
)
function Write-LogMessage {
<#
.SYNOPSIS
Console logging helper function.
.DESCRIPTION
For a given set of parameters, will create a standardized log message that can be written to any of
the various output streams.
For more documentation on the available output streams see this:
function New-ReusableCommandArgs {
<#
.SYNOPSIS
Creates a hashtable from the pararmters supplied to the function that has called this function
.DESCRIPTION
Determines which values are actually being used and returns them as a hash table
which can be easily platted to other commands
https://www.briantist.com/how-to/splatting-psboundparameters-default-values-optional-parameters/
#>
/*
Inputs text into vmware console
- VMware console MUST be running at same level as script. e.g elevated or not elevated
- Intiate the hotkey from outside of vmware.
- This is useful for pasting long passwords or scripts
- Usage:
1. Open vmware console
2. Copy some content from your local machine to your clipboard
3. Run the autohotkey script ( elevated if vmware console is running elevated ).
@Geogboe
Geogboe / Get-PatchDownloadURLs.ps1
Created January 12, 2018 17:26
PowerShell Function: Returns all download links for a given patch provided by GUID
function Get-PatchDownloadURLs {
<#
.SYNOPSIS
Returns all download links for a given patch
.DESCRIPTION
A PATCH is not just a KB article ID, at least not in this sense. A patch
is a GUID that represents a KB applied to a **specific** computer.
.NOTES
Why am I doing it like this?
@Geogboe
Geogboe / Invoke-StringMatch.ps1
Created January 12, 2018 17:22
PowerShell function which parses a list of strings and returns the string most closely matching the provided string
function Invoke-StringMatch {
<#
.SYNOPSIS
Parses a list of strings and return the string most closely matching the provided string
.DESCRIPTION
Function will take a providded search string, remove special characters and create an array
out of all the words in the string.
Then, it will loop through this array and check to see if a given word is found in any of