Skip to content

Instantly share code, notes, and snippets.

@codingfreak
codingfreak / Purge-DeletedEntraIdAppRegistrations.ps1
Created April 12, 2026 10:15
Permanently delete all deleted Entra ID appregistrations
Connect-MgGraph -Scopes "Application.ReadWrite.All"
Get-MgDirectoryDeletedItemAsApplication -All | `
ForEach-Object { Remove-MgDirectoryDeletedItem -DirectoryObjectId $_.Id }
# If you want to delete just one with a specific name
Get-MgDirectoryDeletedItemAsApplication -All | `
∙ Where-Object { $_.DisplayName -eq "YOUR_APP_NAME" } | `
∙ ForEach-Object { Remove-MgDirectoryDeletedItem -DirectoryObjectId $_.Id }
@codingfreak
codingfreak / create-rbac-lib.ps1
Last active October 28, 2025 21:18
rbac-roles-generator
param (
[string]$Description = "Provides a mapping with friendly names resolving to build in Azure RBAC Role Ids. See https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles for reference.",
[string]$OutputFileUri = "$PSScriptRoot/azureBuildInRbacRoleIds.bicep",
[string]$ExportVariableName = "azureBuildInRbacRoleIds"
)
$prefix = @"
@export()
@description('$Description')
var $ExportVariableName = {
"@
@codingfreak
codingfreak / sample.ps1
Last active August 22, 2025 08:56
Create federated Azure DevOps service connection
$ErrorActionPreference = 'Stop'
function Invoke-AzureDevOpsRestApi {
# Parameter help description
[CmdletBinding()]
param (
[string]
$OrganizationName = '',
[string]
$ProjectName = '',
[string]
@codingfreak
codingfreak / collect-azure-resource-types.ps1
Last active August 21, 2025 14:41
Runs queries against Azure Graph to analyze the aging of Azure Resource Type stable versions better.
[CmdletBinding()]
param (
[Parameter()]
[string]
$ExistingFile,
[Parameter()]
[array]
$ResourceTypeFilter,
[switch]
$AutoFilterCurrentSubscriptionTypes
@codingfreak
codingfreak / definition.json
Last active November 28, 2023 22:43
Machine init stuff
{
"title": "codingfreaks default init",
"disableWallpaper": true,
"disableSounds": true,
"removeKeyboardDelay": true,
"tryFullScreenTerminal": true,
"requireWindowsTerminal": true,
"phases": [
{
"index": 0,
@codingfreak
codingfreak / Program.cs
Created November 22, 2023 20:05
Playing around with EF Core 8
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Security.Cryptography;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@codingfreak
codingfreak / resolve-enum.tsx
Created November 16, 2023 19:26
Typescript sample for resolving a flag enum from a number
function toValues(value: number) :string[] {
const values: string[] = [];
while (value) {
const bit = value & (~value + 1);
values.push(FileAccess[bit]);
value ^= bit;
}
return values;
}
@codingfreak
codingfreak / generate.ps1
Last active April 15, 2024 09:05
A POSH script which can be executed in a folder containing a csproj file to use [Swashbuckle.AspNetCore.Cli(https://github.com/domaindrivendev/Swashbuckle.AspNetCore#swashbuckleaspnetcorecli) to generate Swagger JSON files using the shell
$ErrorActionPreference = 'Stop'
function Install-DotnetTool() {
<#
.SYNOPSIS
Ensures that the dotnet Swashbuckle CLI is installed locally in this folder.
#>
$configPath = "$PWD/.config/dotnet-tools.json"
if (!(Test-Path $configPath)) {
Write-Host "Creating dotnet tool manifest..." -NoNewline
@codingfreak
codingfreak / Program.cs
Created December 1, 2011 11:29
My code generating only numbers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fare;
namespace DbFillerConsole
{
class Program
{