Skip to content

Instantly share code, notes, and snippets.

View jbfriedrich's full-sized avatar
👨‍💻
Learning more Python 🐍

Jason Friedrich jbfriedrich

👨‍💻
Learning more Python 🐍
View GitHub Profile
@jbfriedrich
jbfriedrich / add_ip_whitelist_vmw_fwrules.ps1
Last active August 29, 2015 14:04
Add whitelisted IPs to VMware firewall rules
##
# Powershell script to add whitelisted IPs to VMware vSphere and VMware vCenter firewall rules.
# Also adding a rule to fix the web console problem in vSphere Web Client
##
# Set execution policy
# AllSigned : Every script must bear a valid signature
# RemoteSigned : Must be signed by a trusted publisher (for example Microsoft)
# Unrestricted : No restrictions whatsoever, every script can run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
@jbfriedrich
jbfriedrich / enable_whitelisted_rdp.ps1
Created July 31, 2014 21:11
Only allow RDP from whitelisted IPs
# Set execution policy
# AllSigned : Every script must bear a valid signature
# RemoteSigned : Must be signed by a trusted publisher (for example Microsoft)
# Unrestricted : No restrictions whatsoever, every script can run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# Whitelisted IPs which are allowed to use the services on this host
$whitelistIPs = "8.8.8.8", "127.0.0.1"
# DisplayNames for the firewall rules for Remote Desktop
@jbfriedrich
jbfriedrich / find_orphaned_VMDKs.ps1
Created January 28, 2015 19:15
Find orphaned VMDKs in VMware vSphere 5.x (found on the VMware forums)
$report = @()
$arrUsedDisks = Get-View -ViewType VirtualMachine | % {$_.Layout} | % {$_.Disk} | % {$_.DiskFile}
$arrDS = Get-Datastore | Sort-Object -property Name
foreach ($strDatastore in $arrDS) {
Write-Host $strDatastore.Name
$ds = Get-Datastore -Name $strDatastore.Name | % {Get-View $_.Id}
$fileQueryFlags = New-Object VMware.Vim.FileQueryFlags
$fileQueryFlags.FileSize = $true
$fileQueryFlags.FileType = $true
$fileQueryFlags.Modification = $true
@jbfriedrich
jbfriedrich / list_rdm_vms.ps1
Created January 28, 2015 19:20
List VMs with Raw Device Mappings (RDMs) in VMware vSphere 5.x
# LIst VMs with Raw Device Mappings (RMDs) in VMWare vSphere 5.x
# More info at VMware KB: http://kb.vmware.com/kb/2001823
Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName | fl
@jbfriedrich
jbfriedrich / list_vm_iops.ps1
Last active August 29, 2015 14:21
Powershell script to create a list with read and write IOPS for every Virtual Machine (average and peak values)
##
# Get a list with average and peak IOPS from all VMs
# Found at: https://www.linkedin.com/grp/post/3992597-5937675088978534402
##
Get-VM | Sort | Select @{N="Name"; E={$_.Name}}, @{N="AvgWriteIOPS"; E={[math]::round((Get-Stat $_ -stat "datastore.numberWriteAveraged.average" -RealTime | Select -Expand Value | measure -average).Average, 1)}}, @{N="PeakWriteIOPS"; E={[math]::round((Get-Stat $_ -stat "datastore.numberWriteAveraged.average" -RealTime | Select -Expand Value | measure -max).maximum, 1)}}, @{N="AvgReadIOPS"; E={[math]::round((Get-Stat $_ -stat "datastore.numberReadAveraged.average" -RealTime | Select -Expand Value | measure -average).Average, 1)}}, @{N="PeakReadIOPS"; E={[math]::round((Get-Stat $_ -stat "datastore.numberReadAveraged.average" -RealTime | Select-Expand Value | measure -max).maximum, 1)}} | Format-Table -autosize | Out-File iops.txt
@jbfriedrich
jbfriedrich / hosts
Created June 18, 2016 14:13
Hosts file to make the Internet not suck as much
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#
# See below for acknowledgements.
# Please forward any additions, corrections or comments by email to
# hosts@someonewhocares.org
@jbfriedrich
jbfriedrich / base.conf
Created September 17, 2018 06:42
Saltstack Profile and Map Examples
dc1-product-base:
provider: vmware-dc1
clonefrom: product-centos7-base
devices:
cd:
CD/DVD drive 1:
device_type: client_device
mode: passthrough
disk:
@jbfriedrich
jbfriedrich / update_plex.sh
Last active November 4, 2018 19:07
Check if a new Plex version is available, install it and then move the deb package into a directory for archival purposes.
#!/bin/bash
# Some global variables
WGET_BIN='/usr/bin/wget'
JQ_BIN='/usr/bin/jq'
SED_BIN='/bin/sed'
TOOLS_MISSING=0
CHECK_UPDATE_URL='https://plex.tv/api/downloads/1.json'
UPDATE_URL='https://plex.tv/downloads/latest/1?channel=16&build=linux-ubuntu-x86_64&distro=ubuntu'
ARCHIVE_DIR="${HOME}/plex_archive"
@jbfriedrich
jbfriedrich / convert_posts_to_markdown.py
Created November 13, 2018 12:14
Extracting post title, slug and content from a Ghost 2.x backup and import it to a write.as blog
#!/usr/bin/env python3
"""
Convert HTML posts that we extract via JQ, into Markdown formatted files (one file per post, title as filename)
"""
import json
import html2text
import sys
import argparse
@jbfriedrich
jbfriedrich / git-clearHistory
Created July 5, 2019 13:29 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git