Skip to content

Instantly share code, notes, and snippets.

View Get-CimInstance
PS C:\users\btm\Documents\dcom> Get-CimInstance -ClassName Win32_DCOMApplicationSetting -Property * -Filter 'AppID="{37399C92-DC3F-4B55-AE5B-811EE82398AD}"' |fl
Caption : AppServiceContainerBroker
Description : AppServiceContainerBroker
SettingID :
AppID : {37399c92-dc3f-4b55-ae5b-811ee82398ad}
AuthenticationLevel :
CustomSurrogate :
EnableAtStorageActivation : False
@btm
btm / google_takeout_music_rename.rb
Created Mar 31, 2021
Script to rename Google Takeout Youtube music uploads
View google_takeout_music_rename.rb
# terrible script for reading the music-uploads-metadata.csv file that Google Takeout includes when you download
# Youtube Music 'uploads' (which were Google Play Music songs/uploads).
#
# tries to identify the corresponding file and add artist/album/track to the mp3 tags
# use another tool like MediaMonkey afterward to rename the files, add cover art, etc.
#
# It's hard to separate tracks with the same name. Deal with them by hand.
#
# This worked for about 90% of my mp3s. Your mileage may vary. No promises or guarantees.
# This is hacked together. Works for me. Use at your own risk.
@btm
btm / A-launchctl_parse.rb
Last active Jun 4, 2020
parsing 'launchctl print' even though apple says not to because we are wild and crazy kids
View A-launchctl_parse.rb
require "pp"
WORD_REGEX = '([\w.:\/\(\)" -]+)' # basically match everything but [{}=>]
launchctl_output = `launchctl print system/com.opscode.chef-client`
hash = { }
hash_index = [ ]
launchctl_output.each_line do |line|
case line
@btm
btm / 1-README.txt
Created Nov 9, 2015
chef bootstrap template to use old ohai hostname plugin via custom plugins
View 1-README.txt
This bootstrap template will download the old ohai hostname plugin from github and use it as a custom plugin on bootstrap.
https://github.com/chef/ohai/issues/420
USE:
1. download and place chef-full-old-hostname.erb in ~/.chef/bootstrap/ on your workstation
2. pass "--bootstrap-template chef-full-old-hostname" to your knife bootstrap command
This requires Ohai 8.6.0+, which should be included in Chef 12.4.2+
@btm
btm / report.md
Last active Aug 29, 2015
Chef Client 12.1.0 release post-mortem
View report.md

Post-mortem Report

Post-mortem Facilitator: Bryan McLellan

  1. Failure Happens. Mistakes Happen. This is a blameless Post Mortem.
  2. We assume everyone participating in the project wants to do a good job.
  3. We will not focus on the past events as they pertain to "could've", "should've", etc.
  4. All follow up action items must be actionable and have a participating individuals commitment to implement, design, or otherwise achieve them.

Description

@btm
btm / gist:7cb421f5fe7d1003083a
Created Mar 18, 2015
Chef Postmortem Template
View gist:7cb421f5fe7d1003083a
# INCIDENT DATE - INCIDENT TYPE
## Meeting
#### Waiving meetings
In some cases the IC might determine that a PM meeting for the incident isn't needed.
If the IC decides to waive the meeting please replace the `Meeting` section with a
note indicating the meeting has been waived (example: `Meeting waived: Paul Mooring`)
@btm
btm / wua.rb
Created Oct 27, 2014
Determine if a KB is installed via win32ole on ruby
View wua.rb
# Author:: Bryan McLellan <btm@loftninjas.org>
# Copyright:: Copyright 2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@btm
btm / btm-dsm.log
Last active Aug 29, 2015
DISM API in Ruby via FFI
View btm-dsm.log
From 32bit run:
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: <----- Starting DismApi.dll session -----> - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: Version 6.3.9600.17031 - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: Parent process command line: "C:\opscode\chef\embedded\bin\ruby.exe" dism.rb - DismInitializeInter nal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 Enter DismInitializeInternal - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 Input parameters: Log
@btm
btm / kb.rb
Last active Aug 29, 2015
Use ruby to search Windows Updates for KB2918614
View kb.rb
require 'rubygems'
require 'win32ole'
kb = "KB2918614"
start_time = Time.now
puts "Starting search for #{kb} at #{start_time}"
update_session = WIN32OLE.new("Microsoft.Update.Session")
update_searcher = update_session.CreateUpdateSearcher
update_searcher.Search('IsHidden=1 and IsInstalled=1')
View gist:7be7c484b8d8ce737441
# Test DNS on Windows
wmi = WmiLite::Wmi.new
host = wmi.first_of('Win32_ComputerSystem')
hostname = "#{host['name']}"
machinename = "#{host['name']}"
x = 0
while x < 10