Microsoft 365 管理者の皆さまは、部門異動や組織改編などに合わせて配布グループ(メーリングリスト)のメンバー追加を一気に行いたい場面が多いと思います。
本記事では、PowerShell を使って次の 2 つの作業を一本のスクリプトで自動化する方法を紹介します。
- CSV に記載したユーザーを既存配布グループへ一括追加します。
- 追加したユーザーに「メールボックス所有者として送信する(Send-As)」権限を付与します。
環境、前提条件
- ExchangeOnlineManagement モジュール(V3 以上)がインストール済みであること。
- 対象のメーリングリストグループが既に存在していること。
- 実行アカウントが「Recipient Management」または「Organization Management」ロールを保持していること。
実行手順
CSV ファイルの準備
以下のように、配布グループへ一括登録するユーザーや連絡先は、CSV 形式のテキスト ファイルに 1 行 1 アドレスでまとめ、保存します。
1 行目が列名 "EmailAddress"、2 行目以降に追加対象メールアドレスを記載します。

補足、注意点を以下に記載します。
- CSVファイルの文字コードはUTF-8で保存します。
- Excelで作成する場合は、セル内に余分な空白やタブが入らないようします。
- ダブルクォーテーション("")やカンマ(,)は不要です。
スクリプトの実行
CSVファイルを準備後、以下スクリプトをPowerShellで実行します。
#================================================================
# 配布グループへメンバー追加 + Send-As 付与 一括処理スクリプト
#================================================================
# ▼変更が必要なパラメーター
$tenantDomain = "example.com" # 自社ドメイン
$adminUPN = "admin@$tenantDomain" # 接続アカウント
$groupAddress = "jp-sales@$tenantDomain" # 配布グループ
$csvPath = "C:\Scripts\members.csv" # CSV の場所
# ▼内部ドメイン判定用正規表現(ドットはエスケープ)
$internalRegex = "@" + ($tenantDomain -replace '\.', '\\.') + "$"
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName $adminUPN
# 既存メンバーと既存 Send-As 一覧をキャッシュします。
$existingMembers = Get-DistributionGroupMember -Identity $groupAddress |
Select-Object -ExpandProperty PrimarySmtpAddress
$existingSendAs = Get-RecipientPermission -Identity $groupAddress |
Where-Object { $_.AccessRights -contains 'SendAs' } |
Select-Object -ExpandProperty Trustee
$rows = Import-Csv -Path $csvPath
foreach ($row in $rows) {
$mail = $row.EmailAddress.Trim()
if ([string]::IsNullOrWhiteSpace($mail)) { continue }
# 1 メンバー追加
if ($existingMembers -notcontains $mail) {
# 外部アドレスは MailContact を自動生成します。
if ($mail -notmatch $internalRegex) {
if (-not (Get-MailContact -Identity $mail -ErrorAction SilentlyContinue)) {
$alias = ([guid]::NewGuid()).Guid.Substring(0,8)
New-MailContact -Name $mail -ExternalEmailAddress $mail -Alias $alias | Out-Null
Write-Host "MailContact 作成: $mail" -ForegroundColor Cyan
}
}
Add-DistributionGroupMember -Identity $groupAddress -Member $mail -BypassSecurityGroupManagerCheck
Write-Host "メンバー追加完了: $mail" -ForegroundColor Green
$existingMembers += $mail
}
else {
Write-Host "既にメンバー: $mail" -ForegroundColor Yellow
}
# 2 Send-As 権限付与
if ($existingSendAs -notcontains $mail) {
Add-RecipientPermission -Identity $groupAddress -Trustee $mail -AccessRights SendAs -Confirm:$false
Write-Host "Send-As 付与完了: $mail" -ForegroundColor Green
$existingSendAs += $mail
}
else {
Write-Host "既に Send-As 権限あり: $mail" -ForegroundColor Yellow
}
# スロットリング回避(必要に応じて有効化)
# Start-Sleep -Milliseconds 200
}
Disconnect-ExchangeOnline -Confirm:$false
スクリプト実行が成功した場合は以下のように表示されます。
"メンバー追加完了: suzuki@example.com""Send-As 付与完了: suzuki@example.com"
また、併せてExchange管理センター上でも対象のメーリングリストにメンバー追加、Send-As権限が付与されているか確認します。
スクリプトのポイント
- 自社ドメインを変数化しています。$tenantDomain を変更するだけで別テナントへ流用できます。
- 既存メンバーの除外 では $existingMembers を使い重複登録を防いでいます。
- グループ管理者チェックのバイパス として -BypassSecurityGroupManagerCheck を指定しています。
- 外部アドレスが存在する場合は New-MailContact で連絡先を自動生成してから追加します。
- スロットリング対策 として Start-Sleep をスクリプトに記載しています。
まとめ
今回ご紹介した CSV+PowerShell スクリプトを利用すると、GUI では手間と時間がかかる「メンバー追加」と「Send-As 権限付与」を数分で自動化できます。
ぜひ自社環境に合わせてカスタマイズし、業務効率化に役立てていただけますと幸いです。