Skip to content

Instantly share code, notes, and snippets.

View MattHodge's full-sized avatar

Matthew Hodgkins MattHodge

View GitHub Profile
<#
.SYNOPSIS
Send a message when a Storage Spaces Pool, Virtual or Physical Disk is no longer of Health Status.
.DESCRIPTION
Windows 2012 R2 Storage Spaces provides CmdLets to monitor the status of Pool, Virtual or Physical Disk.
This script will send an alert if it notices anything is not Healthy, with the name of the server and the details.
Set this task up inside Task Scheduler
dsc_resource 'get-dsc-resource-kit' do
resource :Archive
property :ensure, 'Present'
property :path, "#{ENV['USERPROFILE']}/Downloads/DSC Resource Kit 03282014.zip"
property :destination, "#{ENV['PROGRAMW6432']}/WindowsPowerShell/Modules"
end
@MattHodge
MattHodge / nginx.log
Last active August 29, 2015 14:16
Chef Error 500
2014/10/24 14:57:33 [error] 1051#0: *17 connect() failed (111: Connection refused) while connecting to upstream, client: <SERVERIP>, server: chef.<REPLACED>.com, request: "GET /users/hodge HTTP/1.1", upstream: "http://127.0.0.1:8000/users/hodge", host: "chef.<REPLACED>.com:443"
2014/10/24 14:57:33 [error] 1051#0: *19 connect() failed (111: Connection refused) while connecting to upstream, client: <SERVERIP>, server: chef.<REPLACED>.com, request: "GET /users/hodge HTTP/1.1", upstream: "http://127.0.0.1:8000/users/hodge", host: "chef.<REPLACED>.com:443"
2015/03/06 17:02:47 [error] 1984#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: <WORKSTATIONIP>, server: chef.<REPLACED>.com, request: "GET /search/node?q=tags%253A*jfk*%2520OR%2520roles%253A*jfk*%2520OR%2520fqdn%253A*jfk*%2520OR%2520addresses%253A*jfk*&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000 HTTP/1.1", upstream: "http://127.0.0.1:8000/search/node?q=tags%253A*jfk*%2520OR%2520roles%253A*jfk*%2520OR%2520fqdn%253A*jfk*%
@MattHodge
MattHodge / CreateCertificate.ps1
Last active August 29, 2015 14:22
AUTOMATING WITH JENKINS AND POWERSHELL ON WINDOWS – PART 2
# Enter the bin directory inside the OpenSSL install folder
cd C:\OpenSSL-Win64\bin
# Generate a self-signed SSL certificate. Be sure to update your paths if required.
openssl req -newkey rsa:4096 -nodes -sha256 -keyout C:\temp\jenkins.key -x509 -days 365 -out C:\temp\jenkins.crt -config C:\OpenSSL-Win64\bin\openssl.cfg
# Stop the Jenkins Server
Stop-Service -Name Jenkins
# Edit the Jenkins configuration file
notepad 'C:\Program Files (x86)\Jenkins\jenkins.xml'
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=-1 --httpsPort=443 --httpsCertificate=C:/ssl/jenkins.crt --httpsPrivateKey=C:/ssl/jenkins.key</arguments>
# Start the Jenkins Server
Start-Service -Name Jenkins
# Ensure the build fails if there is a problem.
# The build will fail if there are any errors on the remote machine too!
$ErrorActionPreference = 'Stop'
# Create a PSCredential Object using the "User" and "Password" parameters that you passed to the job
$SecurePassword = $env:Password | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $env:User, $SecurePassword
# Invoke a command on the remote machine.
# It depends on the type of job you are executing on the remote machine as to if you want to use "-ErrorAction Stop" on your Invoke-Command.
# Ensure the build fails if there is a problem.
# The build will fail if there are any errors on the remote machine too!
$ErrorActionPreference = 'Stop'
# Create a password variable using the stored password from the Jenkins Global Passwords
$SecurePassword = $env:PasswordForHodge | ConvertTo-SecureString -AsPlainText -Force
# If remoting to a machine with domain credentials, use "DOMAIN\YourUserName"
# If remoting to a machine on a workgroup, use "\YourUserName"
$User = "\Hodge"