Created
November 28, 2025 22:30
-
-
Save StartAutomating/d65a89645446d7835803193300d52e50 to your computer and use it in GitHub Desktop.
Gist get me a GitHub User's BlueSky profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Get a GitHub user's BlueSky | |
| .DESCRIPTION | |
| Gets an At Protocol Handle / BlueSky profile link for a GitHub user | |
| .EXAMPLE | |
| ./GitHubBlueSky StartAutomating | |
| #> | |
| param([string]$UserName) | |
| # Globally cache to avoid repeat request (use script: inside of a function or module) | |
| if (-not $global:GitHubProfileCache) { | |
| $global:GitHubProfileCache = [Ordered]@{} | |
| } | |
| # Get the user profile | |
| if (-not $global:GitHubProfileCache[$UserName]) { | |
| $global:GitHubProfileCache[$UserName] = Invoke-WebRequest "https://github.com/$UserName" | |
| } | |
| # Skip empty entries | |
| if (-not $global:GitHubProfileCache[$UserName]) { return } | |
| $blueSkyProfile = ($global:GitHubProfileCache[$UserName].Links -match 'bsky' | Select-Object -ExpandProperty Href) | |
| # If we have a bluesky profile | |
| if ($blueSkyProfile) { | |
| # output an object linking the profiles | |
| [PSCustomObject]@{ | |
| GitUserName = $UserName | |
| GitHubProfile = "https://github.com/$UserName" | |
| # and extract the username from the last segment | |
| AtUserName = ($blueSkyProfile -as [uri]).Segments[-1] -replace '/' | |
| BlueSkyProfile = $blueSkyProfile | |
| } | |
| } else { | |
| # Otherwise, just output the git info | |
| [PSCustomObject]@{ | |
| GitUserName = $UserName | |
| GitHubProfile = "https://github.com/$UserName" | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment