Skip to content

Instantly share code, notes, and snippets.

View MattHodge's full-sized avatar

Matthew Hodgkins MattHodge

View GitHub Profile
@MattHodge
MattHodge / (CLIENT SIDE) check-service.ps1
Last active August 29, 2015 14:22
Sensu Windows Check
Param
(
# Param1 help description
[Parameter(Mandatory=$true)]
$ServiceName
)
$status = (Get-Service -name $ServiceName)
if ($status.Status -ne 'Running')
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
# Makes PowerShell pull you up about everything..
Set-StrictMode -Version Latest
# YOu don't need to put this in usually, but just to make sure in your ise.
$ErrorActionPreference = "Continue"
#Dot Source required Function Libraries
#. "Logging_Functions.ps1"
#----------------------------------------------------------[Declarations]----------------------------------------------------------
@MattHodge
MattHodge / vagrant_powershell_provision.rb
Created June 17, 2015 01:20
Vagrant PowerShell Provision
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "mwrock/Windows2012R2"
config.vm.guest = :windows
config.vm.communicator = "winrm"
@MattHodge
MattHodge / escapinghtml.ps1
Last active August 29, 2015 14:26
Escaping PowerShell
$title = "This is Matt's Page"
$price = 20
$color = 'red'
$html =
"
<HTML>
<HEAD>
<TITLE>$($title)</TITLE>
<BODY>
<font color=""$($color)"">
@MattHodge
MattHodge / Add Path Environment Variable.ps1
Created November 8, 2015 04:53
Add Path Environment Variable
# Requires the Add-PathVariable function from my PowerShell Profile
Add-PathVariable -Path 'C:/opscode/chefdk/embedded/bin'
@MattHodge
MattHodge / 04_Blog_Win10_Development_PC_Vagrant.ps1
Last active November 8, 2015 13:04
04_Blog_Win10_Development_PC_Vagrant.ps1
# Install vagrant plugins
vagrant plugin install 'vagrant-berkshelf'
vagrant plugin install 'vagrant-dsc'
vagrant plugin install 'vagrant-omnibus'
vagrant plugin install 'vagrant-reload'
vagrant plugin install 'vagrant-vbguest'
vagrant plugin install 'vagrant-vbox-snapshot'
vagrant plugin install 'vagrant-winrm'
vagrant plugin install 'winrm-fs'
@MattHodge
MattHodge / 01_Blog_Win10_Development_PC_PSProfile.ps1
Last active November 8, 2015 13:04
01_Blog_Win10_Development_PC_PSProfile.ps1
# Create a symlink to the profile in your shared drive
cmd /c mklink $PROFILE D:\DataHodge\Dropbox\PSProfile\Microsoft.PowerShell_profile.ps1
# Load the profile into the current session
. $PROFILE
@MattHodge
MattHodge / 07_Blog_PSStringFormating_HashTables_WebSite.ps1
Last active November 8, 2015 13:05
Description for 07_Blog_PSStringFormating_HashTables_WebSite.ps1
$webData = @{
name = 'Matt'
fontcolor = 'red'
type = 'beer'
price = '6.00'
age = 29
}
$htmlPage = "
@MattHodge
MattHodge / 06_Blog_PSStringFormating_HashTables_DoubleDoubleQuotes.ps1
Created August 16, 2015 11:51
Description for 06_Blog_PSStringFormating_HashTables_DoubleDoubleQuotes.ps1
# When our string contains double quotes
$myItem = @{
name = 'Matt'
age = 29
}
$myStringBackTicks = "The user `"$($myItem.name)`" is of age `"$($myItem.age)`""
$myStringDoubleQuotes = "The user ""$($myItem.name)"" is of age ""$($myItem.age)"""
Write-Output $myStringBackTicks
@MattHodge
MattHodge / 05_Blog_PSStringFormating_HashTables_SingleQuotes.ps1
Created August 16, 2015 11:51
Description for 05_Blog_PSStringFormating_HashTables_SingleQuotes.ps1
# When our string contains single quotes
$myItem = @{
name = 'Matt'
age = 29
}
$myString = "The user '$($myItem.name)' is of age '$($myItem.age)'"
Write-Output $myString