Types/OpenPackage.Source/AtRecord.ps1

<#
.SYNOPSIS
    Gets at records
.DESCRIPTION
    Gets records from the at protocol.
.EXAMPLE
    Get-OpenPackage at://mrpowershell.com/app.bsky.actor.profile
#>

param(
# Who [did](https://atproto.com/specs/did) (decentralized identifier)
[Parameter(Mandatory)]
[Alias('DectralizedIdentifier')]
[string]
$did,

# What collection or type
[Parameter(Mandatory)]
[string]
$collection,

# What is the record key?
[Parameter(Mandatory)]
[string]
$rkey,

# Where is the data?
[string]
$pds = "https://bsky.social",

# Any additional headers to pass into a web request.
[Alias('Header')]
[Collections.IDictionary]
$Headers
)

# Construct the XRPC url to that record
$xrpcUrl = "$(
    # Be fault tolerant with the pds format
    if ($pds -like 'https://*') {
        # just trim trailing slashes from https urls
        $pds -replace '/$'
    } else {
        # and prefix anything else by https://
        "https://$pds" -replace '/$'
    }
)/xrpc/com.atproto.repo.getRecord?repo=$(
    $did
)&collection=$(
    $collection
)&rkey=$(
    $Rkey
)"


# and go fetch.
try {
    if ($headers) {
        Invoke-RestMethod -Uri $xrpcUrl -Headers $header
    } else {
        Invoke-RestMethod -Uri $xrpcUrl
    }
    
} catch {
    Write-Verbose "$xrpcUrl - $_"
}