Skip to content

Instantly share code, notes, and snippets.

View devblackops's full-sized avatar
🎯
Lookin' for code in all the wrong places

Brandon Olin devblackops

🎯
Lookin' for code in all the wrong places
View GitHub Profile
@devblackops
devblackops / gist:56b55fbc82b96700633b
Last active August 29, 2015 14:24
Modify VMware OS customization spec
PowerCLI C:\> $spec = get-oscustomizationspec win2k12_dsc
PowerCLI C:\> $spec | fl guirunonce
GuiRunOnce : {c:\windows\system32\windowspowershell\v1.0\powershell.exe c:\temp\dscbootstrap.ps1}
PowerCLI C:\> $specClone = new-oscustomizationspec -OSCustomizationSpec $spec -Type NonPersistent
PowerCLI C:\> $specClone | fl guirunonce
GuiRunOnce : {c:\windows\system32\windowspowershell\v1.0\powershell.exe c:\temp\dscbootstrap.ps1}
@devblackops
devblackops / DSCBootstrap
Last active August 29, 2015 14:24
Configure DSC client with given GUID
param(
[guid]$guid
)
$computerName = $env:COMPUTERNAME
[DSCLocalConfigurationManager()]
Configuration LCMPull {
param(
[string]$computer,
[guid]$guid,
@devblackops
devblackops / Invoke-DscResource_Test.ps1
Last active December 17, 2015 07:19
How can I make Import-DscResource dynamic? I won't know ahead of time what DSC resources will be needed as all the required parameters and the type of resource is passed in by the user.
# Example data to feed into script.
# In real life, this is an array of hashes
# with the required parameters for 1 or more
# custom DSC resources to provision infrastructure
# The types of resources to create will only be
# known at runtime
$ResourceData = @(
@{
Name = 'fileShareTest'
Verifying that +devblackops is my blockchain ID. https://onename.com/devblackops
@devblackops
devblackops / chefquery.ps1
Created January 7, 2016 00:25
PowerShell script to query Chef nodes via REST API. Assumes you have the BouncyCastle.Crypto.dll in the same folder as the script.
function Get-Base64 {
param (
$data
)
# if the $data is a string then ensure it is a byte array
if ($data.GetType().Name -eq "String") {
$data = [System.Text.Encoding]::UTF8.GetBytes($data)
}
@devblackops
devblackops / vm_move.ps1
Created February 15, 2016 18:42
PowerShell function to perform either local or Cross vCenter vMotion of a VM. Executes extra validation including pings, tracert, and Pester tests pre and post migration.
#Requires -RunAsAdministrator
#Requires -module VMware.VimAutomation.Core, VMware.VimAutomation.Vds, Pester, DrsRule
[cmdletbinding(SupportsShouldProcess)]
param(
[parameter(Mandatory, ValueFromPipelineByPropertyName = $true)]
[Alias('Name')]
[string]$VMName,
[parameter(Mandatory, ValueFromPipelineByPropertyName = $true)]

OVF Thoughts

Here are few thoughts on potential improvements to the Operation Validation Framework module for executing Pester tests.

These ideas are meant to improve the flexibility of the Operation Validation Framework by adding the capability to override parameters used in Pester tests with user provided values. This would allow generic OVF modules that test core Infrastructure technologies to be published to public repositories like the PowerShell Gallery while allowing the user to tailor the tests to their environment.

Pester script defaults

@devblackops
devblackops / Custom-Attribute.ps1
Last active January 23, 2017 17:12
Custom attributes attached to PowerShell function
Add-Type -TypeDefinition @"
namespace PoshBot {
public class BotCommand : System.Attribute {
public string Description { get; set; }
}
}
"@
function Foo {
[PoshBot.BotCommand(Description = 'This is a custom function description')]
@devblackops
devblackops / Shorten-Url.ps1
Created September 7, 2017 03:51
PoshBot function to shorten a url
function Url {
[PoshBot.BotCommand(
Command = $false,
TriggerType = 'Regex',
Regex = '^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)|[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}[^ ]+'
)]
[cmdletbinding()]
param(
[parameter(Mandatory, ValueFromRemainingArguments)]
[object[]]$Arguments,

Keybase proof

I hereby claim:

  • I am devblackops on github.
  • I am devblackops (https://keybase.io/devblackops) on keybase.
  • I have a public key ASDd4DO8BeRC7l3kECkdj8Z6NHEdIeP0dNK50DRr1sBWUwo

To claim this, I am signing this object: