Skip to content

Instantly share code, notes, and snippets.

View devblackops's full-sized avatar
🎯
Lookin' for code in all the wrong places

Brandon Olin devblackops

🎯
Lookin' for code in all the wrong places
View GitHub Profile
$tenant = '<tenant-id>'
$subscription = '<subscription-id>'
$clientId = '<client-id>'
$clientSecret = '<client-secret>'
# Log into Azure w/ Service Principal
$creds = [pscredential]::new($clientId, ($clientSecret | ConvertTo-SecureString -AsPlainText -Force))
Connect-AzAccount -TenantId $tenant -SubscriptionId $subscription -Credential $creds -ServicePrincipal > $null
# Get auth token
@devblackops
devblackops / TrackChromeUsage.ps1
Last active December 12, 2019 00:30
Track Chrome processes for graphing at the console.
# Put these functions in the profile.ps1 to start and stop Chrome usage tracking.
# Display your Chrome usage by running "Show-ChromeUsage"
# Track Chrome usage
function Start-ChromeUsageTracking {
$job = Start-Job -Name ChromeTracker -ScriptBlock {
while ($true) {
$now = [datetime]::Now.ToString('s')
$tabs = (Get-Process chrome -ErrorAction SilentlyContinue).Count
$log = Join-Path ([IO.Path]::GetTempPath()) 'chrome_usage.csv'
@devblackops
devblackops / tf_plan.txt
Created January 15, 2020 17:12
Azure Front Door Terraform plan output
# azurerm_frontdoor.fd will be created
+ resource "azurerm_frontdoor" "fd" {
+ cname = (known after apply)
+ enforce_backend_pools_certificate_name_check = true
+ id = (known after apply)
+ load_balancer_enabled = true
+ location = "eastus"
+ name = "XXXXX-fd1"
+ resource_group_name = "tf_XXXXX"
@devblackops
devblackops / SlackRtmTlsBugRepo.ps1
Created March 5, 2020 17:23
Minimal reproduction of connecting to Slack's RTM websocket API to receive messages
[cmdletbinding()]
param()
function Connect-SlackRtm {
[cmdletbinding()]
param(
[string]$Token
)
$loginData = @{}
[cmdletbinding()]
param()
function Connect-SlackRtm {
[cmdletbinding()]
param(
[string]$Token
)
$loginData = @{}
# Registered an AAD group with Priviledged Identity Management (PIM)
function Get-PimToken {
<#
.SYNOPSIS
Gets the Azure auth token for PIM.
#>
[cmdletbinding()]
param()