Skip to content

Instantly share code, notes, and snippets.

@eugrus
Created February 2, 2026 18:01
Show Gist options
  • Select an option

  • Save eugrus/21555a1740d6fd4b9060bbfedf6baf1c to your computer and use it in GitHub Desktop.

Select an option

Save eugrus/21555a1740d6fd4b9060bbfedf6baf1c to your computer and use it in GitHub Desktop.
Gibt die Adresse eines Unternehmens aus dem Register von Data Privacy Framework aus. Vor der Nutzung die Excel-Datei von https://www.dataprivacyframework.gov/list herunterladen und in CSV konvertieren.
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$SearchTerm,
[Parameter(Mandatory=$false)]
[string]$CsvPath = ".\DataPrivacyFrameworkParticipantsList.csv",
[Parameter(Mandatory=$false)]
[switch]$ShowInactive
)
# Fehlerbehandlung aktivieren
$ErrorActionPreference = "Stop"
function Format-Address {
param($Participant)
$legalName = $Participant.'Legal Name'
$street = $Participant.Street
$city = $Participant.City
$state = $Participant.State
$postalCode = $Participant.'Postal Code'
$addressParts = @()
if (![string]::IsNullOrWhiteSpace($legalName)) { $addressParts += $legalName.Trim() }
if (![string]::IsNullOrWhiteSpace($street)) { $addressParts += $street.Trim() }
$cityStateParts = @()
if (![string]::IsNullOrWhiteSpace($city)) { $cityStateParts += $city.Trim() }
if (![string]::IsNullOrWhiteSpace($state)) { $cityStateParts += $state.Trim() }
if (![string]::IsNullOrWhiteSpace($postalCode)) { $cityStateParts += $postalCode.Trim() }
if ($cityStateParts.Count -gt 0) {
$addressParts += ($cityStateParts -join ' ')
}
return ($addressParts -join ', ')
}
try {
if (-not (Test-Path $CsvPath)) {
Write-Error "CSV-Datei nicht gefunden: $CsvPath"
exit 1
}
# Import mit UTF8-Encoding
$participants = Import-Csv -Path $CsvPath -Delimiter ';' -Encoding UTF8
# Suche und Filterung
$results = $participants | Where-Object {
$matchesName = ($_.'Public Display Name' -like "*$SearchTerm*") -or ($_.'Legal Name' -like "*$SearchTerm*")
$isActive = $_.Status -like "*Active*"
if ($ShowInactive) {
$matchesName
} else {
$matchesName -and $isActive
}
}
# Adressen generieren und durch 'Select-Object -Unique' Dubletten (EU/UK/CH Zeilen) entfernen
$uniqueAddresses = $results | ForEach-Object {
Format-Address -Participant $_
} | Select-Object -Unique
$matchCount = ($uniqueAddresses | Measure-Object).Count
if ($matchCount -eq 0) {
Write-Host "Keine Treffer gefunden für: '$SearchTerm'" -ForegroundColor Yellow
if (-not $ShowInactive) {
Write-Host "Hinweis: Verwenden Sie -ShowInactive um auch inaktive Teilnehmer anzuzeigen." -ForegroundColor Gray
}
}
else {
# Finale Ausgabe der bereinigten Adressliste
$uniqueAddresses | Write-Output
}
}
catch {
Write-Error "Fehler beim Verarbeiten der CSV-Datei: $_"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment