Skip to content

Instantly share code, notes, and snippets.

@rbrayb
Created February 22, 2023 05:05
Show Gist options
  • Save rbrayb/c132568d7ecedb67c43a5119e75631cc to your computer and use it in GitHub Desktop.
Save rbrayb/c132568d7ecedb67c43a5119e75631cc to your computer and use it in GitHub Desktop.
# Set the Azure AD B2C tenant name and endpoint
$tenantName = "tenantname"
# Connect to Azure AD B2C
Connect-AzureAD -Tenant "$tenantName.onmicrosoft.com"
# Import the Excel spreadsheet as a PowerShell object
$excelFilePath = "C:\...\Downloads\AuditLogs_2023–02–22.xlsx"
$worksheetName = "AuditLogs_2023–02–22"
$excelData = Import-Excel -Path $excelFilePath -WorksheetName $worksheetName
# Loop through each row of the spreadsheet
foreach ($row in $excelData) {
# Get the Object ID from the current row
$objectId = $row.Target1ObjectId
# Use the Azure AD PowerShell module to get the user's username
$user = Get-AzureADUser -ObjectId $objectId | Select DisplayName
# Output the username to the console
Write-Host "Username: $user"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment