Skip to content

Instantly share code, notes, and snippets.

@starkfell
starkfell / get-azure-account-access-token.sh
Created June 26, 2024 11:42
Retrieve the Access Token of the current Azure Account you are logged in as.
# Modified version of https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53#file-jwt-decode-sh that
# retrieves the Access Token of the current Azure Account you are logged in as.
# will not work in all cases, see https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53#gistcomment-3439904
function jwt-decode() {
sed 's/\./\n/g' <<< $(cut -d. -f1,2 <<< $1) | base64 --decode | jq
}
az account show
@starkfell
starkfell / cleanup-role-assignments-for-non-existing-principals.sh
Last active January 24, 2024 08:07
Delete Role Assignments for deleted or non-existing Managed Identities, Service Principals, Groups, and Users
#!/bin/bash
: '
Name: cleanup-role-assignments-for-non-existing-principals.sh
Author: Ryan Irujo
Description: This scripts is for resolving the issue in the article below.
https://learn.microsoft.com/en-us/answers/questions/672875/azure-managed-identity-role-assignment-is-not-dele
@starkfell
starkfell / win10.custom.ps1
Last active May 9, 2022 07:09
Customize Window 10 Post Install
# Windows 10 Customize, post-install.
#
$key = 'HKCU:\Control Panel\Desktop'
Set-ItemProperty -Path $key -Name 'WallPaper' -Value ''
Stop-Process -ProcessName explorer
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Value 2
Add-Type -typedefinition "using System;`n using System.Runtime.InteropServices;`n public class PInvoke { [DllImport(`"user32.dll`")] public static extern bool SetSysColors(int cElements, int[] lpaElements, int[] lpaRgbValues); }"; [PInvoke]::SetSysColors(1, @(1), @(0x000000))
Reg Add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" /v "VisualFXSetting" /t REG_DWORD /d 2 /f
Reg Add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" /v "VisualFXSetting" /t REG_DWORD /d 3 /f
Reg Add "HKCU\Control Panel\Desktop" /v "UserPreferencesMask" /t REG_BINARY /d "90 32 07 80 10 00 00 00" /f
@starkfell
starkfell / deploy-ubuntu-20.04-w-cockpit.sh
Last active October 31, 2021 14:18
Deploy Ubuntu 20.04 with Cockpit installed
#!/bin/bash
sudo apt-get update && \
sudo apt-get install -y ca-certificates vim jq curl wget docker.io apt-transport-https lsb-release gnupg net-tools make && \
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null && \
AZ_REPO=$(lsb_release -cs) && \
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list && \
sudo apt-get update && \
sudo apt-get install -y azure-cli && \
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb && \

Choco Install

# Installing Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

choco feature enable -n=allowGlobalConfirmation
choco install git
choco install vscode --params "/NoQuickLaunchIcon"
choco install googlechrome
#!/bin/bash
# wget -O - {URL} | bash
apt-get update -fq && \
apt-get install -q openssl libffi python clang make && \
apt-get install -q openssh nano && \
pip install --user virtualenv
cat << EOF > ~/.bashrc
PATH=$PATH:~/.local/bin
#!/usr/bin/env python3
#
# Name: delete-unattached-managed-disks.py
#
# Author: Ryan Irujo
#
# Description: Python script for removing unattached managed disks in an Azure Subscription.
#
# Notes: You must already be logged into an Azure Subscription for this script to work.
#
#!/usr/bin/env python3
#
# Name: query-rg.py
#
# Author: Ryan Irujo
#
# Description: Script demonstrating how to query for an Azure Resource Group using the Azure CLI and Python.
#
# Notes: You must already be logged into an Azure Subscription for this script to work.
#
# Instructions to Install AzureAD PowerShell on PowerShell Core.
Get-InstalledModule
Install-Module -Name Az -Repository PSGallery -AllowClobber -Force
Install-Module -Name AzureADPreview -Repository PSGallery -AllowClobber -Force
Install-Module -Name 'AzureAD.Standard.Preview' -Repository 'Posh Test Gallery'-SkipPublisherCheck -AllowClobber -Force
Import-Module Az.Resources
Import-Module AzureAD.Standard.Preview