Skip to content

Instantly share code, notes, and snippets.

View bcdady's full-sized avatar
👨‍💻
:terraform:

Bryan Dady bcdady

👨‍💻
:terraform:
View GitHub Profile
@bcdady
bcdady / gist:25065e63e1564ca06b42
Created October 14, 2015 05:03
Set kdiff3 (from TortoiseHG) as Git mergetool
[mergetool "kdiff3"]
cmd = \"c:\program files/TortoiseHg/kdiff3.exe\" '-auto' \"$BASE\" \"$LOCAL\" \"$REMOTE\" '-o' \"$MERGED\"
trustExitCode = false
@bcdady
bcdady / Get-DHCPadapters.ps1
Created May 1, 2015 21:01
PowerShell One-Liner: Enumerate all DHCP enabled Network Adapters via WMI / CIM, using an embedded CIM query as the -Filter
# Step 1, filter network adapters to those that are IP & DHCP enabled
# - this can only be done with the Win32_NetworkAdapterConfiguration class:
Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter 'IpEnabled=True AND DhcpEnabled=True'
# To get a unique handle to any/all network adapters matching the filtered query, retrieve only their Index propery:
(Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter 'IpEnabled=True AND DhcpEnabled=True').Index
# Using the Index property, enumerate objects in the Win32_NetworkAdapter class, with the same Index (aka DeviceID) property:
# - notice the prior Get-CimInstance query gets wrapped in another $(), to force returning only the resulting value into this Filter statement
# - I added | Format-List, because the default Table formatted results truncated the value of the .Name property
@bcdady
bcdady / gist:06ed3e9b0210bae54e70
Created April 28, 2015 12:19
Get Help for all commands in a module
# Quickly list out all commands in a new PowerShell Module, andcheck that they each have useful help content
Get-Command -Module ProfilePal | foreach {get-help $_}
@bcdady
bcdady / gist:e3ac78cd27e4dcd82699
Created April 26, 2015 15:20
Import posh-git module to an existing console (non Git Shell)
# Starting a new PowerShell (PS) console on a Windows OS instance that has GitHub client for Windows installed ...
# Find the local instance of git.exe; it's an 'external' dependency for posh-git
Get-ChildItem -Path $env:LocalAppData\GitHub\ -Filter git.exe -Recurse
# Should return at least 1 instance of git.exe
# Select one and add an alias to it
# I choose the one in \bin\ for example:
New-Alias -Name git -Value $env:LOCALAPPDATA\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\bin\git.exe
@bcdady
bcdady / find-str_PSmod
Last active November 10, 2016 14:45
Find a string within any file included in a PowerShell module
# search string within All Modules
# e.g. find '-function' within any file in a module
$env:PSModulePath | ForEach-Object { $_ -split ';' | Get-ChildItem -Filter *.ps* -Recurse | Select-String -Pattern 'Write-Log' -SimpleMatch}