Skip to content

Instantly share code, notes, and snippets.

View heaths's full-sized avatar

Heath Stewart heaths

View GitHub Profile
@heaths
heaths / Get-ExportedTypes.ps1
Created September 28, 2022 18:30
Gets exported types from one or more assemblies.
[CmdletBinding(DefaultParameterSetName = 'Path')]
param (
[Parameter(ParameterSetName = 'Path', Position = 0, Mandatory = $true)]
[string[]] $Path,
[Parameter(ParameterSetName = 'LiteralPath', Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[Alias('PSPath')]
[string[]] $LiteralPath
)
@heaths
heaths / Add-AzsdkProjectIssues.ps1
Last active June 13, 2022 18:25
Add issues from Azure SDK repositories to a project in the Azure organization
[CmdletBinding(DefaultParameterSetName = 'Repositories', SupportsShouldProcess = $true)]
param (
[Parameter(Mandatory = $true, Position = 0)]
[int] $ProjectNumber,
[Parameter(Mandatory = $true, Position = 1)]
[string[]] $Labels,
[Parameter(ParameterSetName = 'Repositories')]
[Alias("repos")]
@heaths
heaths / Copy-AzSpecifications.ps1
Last active April 5, 2022 22:40
Copies OpenAPI specifications (swaggers) from one version to another for Azure/azure-rest-api-specs repo.
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string] $ServiceDirectory,
[Parameter(Mandatory=$true)]
[string] $ResourceProvider,
[Parameter(Mandatory=$true)]
[string] $SourceVersion,
@heaths
heaths / Measure-Types.ps1
Created November 30, 2021 21:48
Gets information about the number of public types, and public and protected members.
#Requires -Version 5
#Requires -PSEdition Desktop
# Gets information about the number of public types, and public and protected members.
[CmdletBinding(DefaultParameterSetName = 'Path')]
param (
[Parameter(ParameterSetName = 'Path', Position = 0)]
[string[]] $Path,
[Parameter(ParameterSetName = 'LiteralPath', Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
@heaths
heaths / SecureFile.psm1
Last active March 30, 2022 17:21
Use Windows DPAPI to secure files
#Requires -Version 5.0
function Protect-SecureFile {
[CmdletBinding(DefaultParameterSetName = 'Path')]
param (
[Parameter(ParameterSetName = 'Path', Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[string] $Path,
[Parameter(ParameterSetName = 'LiteralPath', Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[Alias('PSPath')]
@heaths
heaths / ConvertTo-Rtf.ps1
Created September 18, 2021 16:10
Script to convert simple text e.g. LICENSE.txt to basic RTF for display in a RichEdit2.0 control
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, Position=0)]
[string] $Path,
[Parameter(Mandatory=$true, Position=1)]
[string] $OutFile,
[Parameter()]
[ValidateNotNullOrEmpty()]
@heaths
heaths / config.yml
Created May 11, 2021 23:04
GitHub CLI aliases
# Aliases allow you to create nicknames for gh commands
aliases:
co: pr checkout
# The following aliases require https://github.com/cli/cli/pull/3519
issues: |-
issue list --json number,title,labels,updatedAt --template '{{range .}}{{if .labels}}{{row (printf "#%v" .number | autocolor "green") .title (pluck "name" .labels | join ", " | printf "(%s)" | autocolor "gray+h") (timeago .updatedAt | printf "about %s" | autocolor "gray+h")}}{{else}}{{row (printf "#%v" .number | autocolor "green") .title "" (timeago .updatedAt | printf "about %s" | autocolor "gray+h")}}{{end}}{{end}}'
users: |-
api graphql --paginate
--template '{{range .data.repository.assignableUsers.nodes}}{{if .status}}{{row (autocolor "green" .login) .name (autocolor "gray+h" .email) (autocolor "yellow" .status.message)}}{{else}}{{row (autocolor "green" .login) .name (autocolor "gray+h" .email) ""}}{{end}}{{end}}'
@heaths
heaths / Test-SampleMetadata.ps1
Last active April 15, 2021 00:20
Find invalid sample metadata in Azure SDK samples' markdowns
[CmdletBinding(DefaultParameterSetName='Path')]
param (
[Parameter(ParameterSetName='Path', Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[string[]] $Path,
[Parameter(ParameterSetName='LiteralPath', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[Alias('PSPath')]
[string[]] $LiteralPath,
[Parameter()]
@heaths
heaths / Remove-AzSdkResourceGroups.ps1
Last active April 1, 2021 20:18
Example script to delete expired or non-standard named resource groups
#!/usr/bin/env pwsh
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#Requires -Version 6.0
#Requires -PSEdition Core
#Requires -Modules @{ModuleName='Az.Accounts'; ModuleVersion='1.6.4'}
#Requires -Modules @{ModuleName='Az.Resources'; ModuleVersion='1.8.0'}
@heaths
heaths / azure-cli.md
Last active November 14, 2023 20:07
Tips and other useful commands for the Azure CLI

Some useful commands for the Azure CLI. Also check out JMESPath specifications for other functions you can use.

Principals

Get the principal OID for a given client ID in a tenant:

# add `--output tsv` to get the raw value without quotes
az ad sp show --id $id --query objectId