Skip to content

Instantly share code, notes, and snippets.

@PFortin93
PFortin93 / CheapServiceChecker
Created August 29, 2018 19:58
Checks if a log file has been written to in the last 30 minutes, Restarts a Windows Service if it has not been
#Checks if JobAlerts has written a log in the last 30 minutes. Restarts it if it has not.
#Should it do stuff, It sends an email
#Pierce Fortin pfortin@smashfly.com
#Logic test on a working service: Change -lt on 28 to -gt
#ScriptSettings
$WaitPeriod = '20' #Wait time in seconds before starting a service if it is in a failed state
$LogPath = 'C:\scripts\jobalerter\runlog.log'
$serviceName = 'ServiceName'
@PFortin93
PFortin93 / Site-X-XSS-PROTECTION.irule
Created June 25, 2018 14:45
Sets X-XSS-PROTECTION header for given array of domains via F5 LTM iRule
#X-XSS-Protection iRule
#By: Pierce Fortin (pfortin@smashfly.com)
#Checks for domain being requested on HTTP_Request, Sets flag for response rewrite if match
#If match, It then checks for X-XSS-Protection as existing, if it doesn't exist it adds one
#If match and header !exist, It adds it.
#v1.0 6/19/2018 Initial write
when RULE_INIT
{
@PFortin93
PFortin93 / Site-X-CONTENT-TYPE.irule
Created June 25, 2018 14:44
Sets Content-Type header for given array of domains for F5 LTM via iRule
#X-FRAME-OPTIONS iRule
#By: Pierce Fortin (pfortin@smashfly.com)
#Checks for domain being requested on HTTP_Request, Sets flag for response rewrite if match
#If match, It then checks for X-Frame-Options as existing, if it doesn't exist it adds X-FRAME-OPTION
#If match and header !exist, It adds it.
#v1.0 6/18/2018 Initial write
when RULE_INIT
{
@PFortin93
PFortin93 / Site-ReferrerHeader.irule
Created June 25, 2018 14:43
Uses F5 LTM iRule to set referrer policy header for given array of domains
#Referrer-Policy iRule
#By: Pierce Fortin (pfortin@smashfly.com)
#Checks for domain being requested on HTTP_Request, Sets flag for response rewrite if match
#If match, It then checks for Referrer-Policy as existing, if it doesn't exist it adds one
#If match and header !exist, It adds it.
#v1.0 6/19/2018 Initial write
when RULE_INIT
{
@PFortin93
PFortin93 / Site-HSTS-Enabler.irule
Created June 25, 2018 14:42
Enables HSTS for a given array of domains via F5 iRule for LTM
#HSTS iRule
#TL;DR Adds HSTS header set to expire 1 year from client accept to domains in array
#By: Pierce Fortin (pfortin@smashfly.com)
#Sets expire data to 1 year from client accept
#Checks for domain being requested on HTTP_Request, Sets flag for response rewrite if match
#If match, It then checks for HSTS as existing, if it doesn't exist it adds HSTS, Based on 1 year from when the client accepted
#If match and header !exist, It adds it.
#v1.0 6/18/2018 Initial write
@PFortin93
PFortin93 / Site-HeaderRemover.irule
Created June 25, 2018 14:42
Removes default IIS headers for a given array of domains
#Header Remover iRule
#By: Pierce Fortin (pfortin@smashfly.com)
#Checks for domain being requested on HTTP_Request, Sets flag for response rewrite if match
#If match, It looks for headers and removes them if they exist.
#v1.0 6/19/2018 Initial write
when RULE_INIT
{
set static::headerremoveDebugOn 0
@PFortin93
PFortin93 / Site-CookieSecurer.irule
Created June 25, 2018 14:41
Sets Cookie security for list of domains in array, allowing some domains to support secure cookies and other sites on the same VIP to be standard cookies
#Cookie Rewrite Rule
#Used to enable secure cookie on response and disable on request,
#Allows client to see secure cookies while server sees standard cookie
#Allows cookie security to only fire on specific set of domains
#Array must be even number of domains for function to work
#By Pierce Fortin PFortin@smashfly.com
#12/12/2017 v 1.0 Original Cookie Rename Profile
#6/18/2018 v 1.1 Replaced rename logic to instead be secure logic
when RULE_INIT
{
@PFortin93
PFortin93 / AdapterSettingsUpdater.ps1
Created February 21, 2018 16:21
A script to configure network adapters to align with this blog post: http://lifeofageekadmin.com/network-performance-vmxnet3-windows-server-2012-r2/
#Fixes Network performance issues on certain Windows Server VMs when under CPU contention
#Set global settings
$adapters = @()
netsh int tcp set global chimney=Disabled
netsh int tcp set global autotuninglevel=Disabled
netsh int tcp set supplemental custom congestionprovider=none
netsh int tcp set global ecncapability=Disabled
netsh int ip set global taskoffload=disabled
netsh int tcp set global timestamps=Disabled
@PFortin93
PFortin93 / BulkHDDadd-vmware.ps1
Created February 20, 2018 16:29
A powershell script to leverage VMware PowerCLI to connect to vSphere/ ESXi and bulk add a standardized hard drive configuration to a set of VMs loaded from a text file.
#Loads a plain text list of VMs, Bulk adds disks based on specs below.
#If you do not have a credential.xml run the following to generate:
#$credpath = "c:\scripts\MyCredential.xml" ##Path to store credentials
#New-Object System.Management.Automation.PSCredential("VSPHERE.LOCAL\Administrator", (ConvertTo-SecureString -AsPlainText -Force "Plaintext password")) | Export-CliXml $credpath
$vmlist = Get-Content -Patch "c:\scripts\vms.txt" #Location of VMList
$size = "40" #Disk Size in GB
$format = "thick" #Disk Format
$datastore = "VMFS07_PURE04" #Datastore name
@PFortin93
PFortin93 / F5 Cookie Rename Repath iRule.tcl
Last active February 6, 2018 21:32
An F5 iRule for renaming and changing the path on a cookie. Useful when proxying content that exists at the root domain of the proxy upstream source but client has brand standards in regards to cookie scope and cookie name which the application does not support.