Hello and Welcome to Microsoft QnA!
Can you try this :
# Set variables for the Azure Cosmos DB endpoint and resource token
$endpoint = "https://your-cosmosdb-account.documents.azure.com"
$resourceToken = "type=resource&ver=1.0&sig=your-signature"
# Set variables for the Azure AD tenant, client ID, and client secret
$tenant = "your-tenant-id"
$clientId = "your-client-id"
$clientSecret = "your-client-secret"
# Get the Azure AD access token
$accessToken = (Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/$tenant/oauth2/v2.0/token" -Body "client_id=$clientId&client_secret=$clientSecret&grant_type=client_credentials&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default").access_token
# Set the authentication header for the Cosmos DB REST API
$authHeader = @{
"Authorization" = "Bearer $accessToken"
"x-ms-date" = [System.DateTime]::UtcNow.ToString("r")
"x-ms-version" = "2017-02-22"
"x-ms-documentdb-is-upsert" = "true"
"x-ms-cosmos-region" = "Central US"
"x-ms-documentdb-session-token" = $resourceToken
}
# Make a request to the Cosmos DB REST API using the authentication header
$response = Invoke-RestMethod -Method Get -Uri "$endpoint/dbs" -Headers $authHeader
# Output the response from the API
$response
Please mark the answer as Completed and upvote in case this helped!
Thank you!