次の方法で共有


Azure portal でユーザーの一覧をダウンロードする

Microsoft Entra の一部である Microsoft Entra ID では、ユーザーの一覧を一括にダウンロードする操作がサポートされています。

必要なアクセス許可

管理者ユーザー、管理者でないユーザーのどちらもユーザーの一覧をダウンロードできます。

ユーザーの一覧をダウンロードするには

ヒント

この記事の手順は、開始するポータルによって若干異なる場合があります。

  1. Microsoft Entra 管理センターにサインインします。

  2. [Microsoft Entra ID] を選びます。

  3. ユーザー>すべてのユーザー>ユーザーをダウンロード を選択します。 既定では、すべてのユーザー プロファイルがエクスポートされます。

  4. [ユーザーをダウンロード] ページで [開始] を選択し、ユーザー プロファイルのプロパティが一覧表示された CSV ファイルを受け取ります。 エラーがある場合は、 [一括操作の結果] ページで結果ファイルをダウンロードして表示できます。 このファイルには、各エラーの理由が含まれています。

    ダウンロードするユーザーの一覧を取得する場所の選択のスクリーンショット。

Note

ダウンロード ファイルには、適用したフィルターのスコープに基づいてフィルター処理されたユーザーの一覧が含まれます。

次のユーザー属性が含まれます。

  • userPrincipalName
  • displayName
  • surname
  • mail
  • givenName
  • objectId
  • userType
  • jobTitle
  • department
  • accountEnabled
  • usageLocation
  • streetAddress
  • state
  • country
  • physicalDeliveryOfficeName
  • city
  • postalCode
  • telephoneNumber
  • mobile
  • authenticationAlternativePhoneNumber
  • authenticationEmail
  • alternateEmailAddress
  • ageGroup
  • consentProvidedForMinor
  • legalAgeGroupClassification

状態の確認

[一括操作の結果] ページでは、保留中の一括要求の状態を確認できます。

[一括操作の結果] ページでの状態の確認のスクリーンショット。

エラーが発生する場合は、[一括操作の結果] ページで結果ファイルをダウンロードして確認できます。 このファイルには、各エラーの理由が含まれています。 ファイルの送信は、指定されたテンプレートと一致し、正確な列名が含まれている必要があります。 一括操作の制限の詳細については、「一括ダウンロード サービスの制限」を参照してください。

一括ダウンロード サービスの制限

それぞれの一括操作アクティビティの最長実行時間は 1 時間であることに注意する必要があります。

Microsoft Entra 管理ポータルでの一括操作は、非常に大規模なテナントではタイムアウトになり失敗する可能性があります。 この制限は、スケーリングの制限が原因である既知の問題です。 Microsoft のエンジニアリング チームは、この制限を最終的には解決する新しいサービスに取り組んでいます。

Note

インポートや作成などの一括操作を実行するときに、一括操作が 1 時間以内に完了しない場合、問題が発生する可能性があります。 この問題を回避するには、バッチごとに処理されるレコードの数を分割することをお勧めします。 たとえば、エクスポートの開始前に、グループの種類またはユーザー名でフィルター処理することで結果セットを制限し、結果のサイズを小さくすることができます。 フィルターを絞り込むことで、実質的には一括操作によって返されるデータを制限していることになります。

この問題のもう 1 つの回避策は、PowerShell を使用して Microsoft Graph API を直接呼び出す方法です。 ユーザーとグループの一括ダウンロードに失敗した場合は、PowerShell コマンドレットの GET-MgGroup -AllGET-MgUser -All を使用することをお勧めします。

以下の PowerShell コード例は、次に関連する一括操作のためのものです。

ユーザー

すべてのユーザーを一括ダウンロードする

# Import the Microsoft Graph module 
Import-Module Microsoft.Graph 

# Authenticate to Microsoft Graph (you may need to provide your credentials) 
Connect-MgGraph -Scopes "User.Read.All" 

# Get all users using Get-MgUser 
$users = Get-MgUser -All -ConsistencyLevel eventual -Property Id, DisplayName, UserPrincipalName,UserType,OnPremisesSyncEnabled,CompanyName,CreationType 

# Specify the output CSV file path 
$outputCsvPath = "C:\\Users\\YourUsername\\Documents\\Users.csv"  

# Create a custom object to store user data 
$userData = @() 

# Loop through each user and collect relevant data 
foreach ($user in $users) { 
    $userObject = [PSCustomObject]@{ 
        Id = $user.Id 
        DisplayName = $user.DisplayName 
        UserPrincipalName = $user.UserPrincipalName 
        UserType = $user.UserType 
        OnPremisesSyncEnabled = $user.OnPremisesSyncEnabled 
        CompanyName = $user.CompanyName 
        CreationType = $user.CreationType 
    } 
    $userData += $userObject 
} 

# Export user data to a CSV file 
$userData | Export-Csv -Path $outputCsvPath -NoTypeInformation 

# Disconnect from Microsoft Graph 
Disconnect-MgGraph 

Write-Host "User data exported to $outputCsvPath" 

ユーザーの一括作成

# Import the Microsoft Graph module 
Import-Module Microsoft.Graph 

# Authenticate to Microsoft Graph (you may need to provide your credentials) 
Connect-MgGraph -Scopes "User.ReadWrite.All" 

# Specify the path to the CSV file containing user data 
$csvFilePath = "C:\\Path\\To\\Your\\Users.csv" 

# Read the CSV file (adjust the column names as needed) 
$usersData = Import-Csv -Path $csvFilePath 

# Loop through each row in the CSV and create users \
foreach ($userRow in $usersData) { 
    $userParams = @{ 
        DisplayName = $userRow.'Name [displayName] Required' 
        UserPrincipalName = $userRow.'User name [userPrincipalName] Required' 
        PasswordProfile = @{ 
            Password = $userRow.'Initial password [passwordProfile] Required' 
        } 
        AccountEnabled = $true 
        MailNickName = $userRow.mailNickName 
    } 
    try { 
        New-MgUser @userParams 
        Write-Host "User $($userRow.UserPrincipalName) created successfully." 
    } catch { 
        Write-Host "Error creating user $($userRow.UserPrincipalName): $($_.Exception.Message)" 
    } 
} 

# Disconnect from Microsoft Graph 
Disconnect-MgGraph 

Write-Host "Bulk user creation completed." 

Note

CSV ファイルに必要な列 (たとえば、DisplayNameUserPrincipalName など) が含まれていることを確認します。 また、CSV ファイル内の実際の列名と一致するようにスクリプトを調整します。

ユーザーの一括削除

# Import the Microsoft Graph module 
Import-Module Microsoft.Graph 

# Authenticate to Microsoft Graph (you may need to provide your credentials) 
Connect-MgGraph -Scopes "User.ReadWrite.All" 

# Specify the path to the CSV file containing user data 
$csvFilePath = "C:\\Path\\To\\Your\\Users.csv" 

# Read the CSV file (adjust the column names as needed) 
$usersData = Import-Csv -Path $csvFilePath 

# Loop through each row in the CSV and delete users 
foreach ($userRow in $usersData) { 
    try { 
        Remove-MgUser -UserId $userRow.UserPrincipalName -Confirm:$false 
        Write-Host "User $($userRow.UserPrincipalName) deleted successfully." 
    } catch { 
        Write-Host "Error deleting user $($userRow.UserPrincipalName): $($_.Exception.Message)" 
    } 
} 

# Disconnect from Microsoft Graph 
Disconnect-MgGraph 

Write-Host "Bulk user deletion completed." 

Note

CSV ファイルに必要な列 (たとえば、UserPrincipalName) が含まれていることを確認します。 また、CSV ファイル内の実際の列名と一致するようにスクリプトを調整します。

グループ

すべてのグループを一括ダウンロードする

Import-Module Microsoft.Graph.Groups 

 # Authenticate to Microsoft Graph (you may need to provide your credentials) 
 Connect-MgGraph -Scopes "Group.Read.All" 

 # Get the group members 
 $groups = Get-MgGroup -All | Select displayName, Id, groupTypes,mail 

 # Create a custom object to store group data 
$groupData = @() 

# Loop through each group and collect relevant data 
foreach ($group in $groups) { 
    if ($group.groupTypes -contains "Unified"){$groupType = "Microsoft 365"} 
    else {$groupType = "Security"} 
    if ($group.groupTypes -contains "DynamicMembership"){$membershipType = "Dynamic"} 
    else {$membershipType = "Assigned"} 
    $groupObject = [PSCustomObject]@{ 
        Id = $group.Id 
        DisplayName = $group.displayName 
        Mail = $group.mail 
        GroupType = $groupType 
        MemebershipType = $membershipType 
    }   
    $groupData += $groupObject 
} 

 # Specify the output CSV file path 
 $outputCsvPath = "C:\\Users\\cewu\\Documents\\Groups.csv" 

 $groupData| Export-Csv -Path $outputCsvPath -NoTypeInformation 
 
 Write-Host "Group members exported to $outputCsvPath" 

グループのメンバーを一括ダウンロードする

Import-Module Microsoft.Graph.Groups 

 # Authenticate to Microsoft Graph (you may need to provide your credentials) 
 Connect-MgGraph -Scopes "Group.Read.All,GroupMember.Read.All" 

 # Set the group ID of the group whose members you want to download 
 $groupId = "your_group_id" 

 # Get the group members 
 $members = Get-MgGroupMember -GroupId $groupId -All | select * -ExpandProperty additionalProperties | Select-Object @( 
                'id'     
                @{  Name       = 'userPrincipalName' 
                    Expression = { $_.AdditionalProperties["userPrincipalName"] } 
                } 
                @{  Name = 'displayName' 
                Expression = { $_.AdditionalProperties["displayName"] } 
                } 
            ) 

 # Specify the output CSV file path 
 $outputCsvPath = "C:\\Users\\YourUserName\\Documents\\GroupMembers.csv" 

 $members| Export-Csv -Path $outputCsvPath -NoTypeInformation 

# Disconnect from Microsoft Graph 
Disconnect-MgGraph 

 Write-Host "Group members exported to $outputCsvPath"  

メンバーを一括で追加する

Import-Module Microsoft.Graph.Groups 

 # Authenticate to Microsoft Graph (you may need to provide your credentials) 
 Connect-MgGraph -Scopes "GroupMember.ReadWrite.All" 

# Import the CSV file 
$members = Import-Csv -Path "C:\path\to\your\file.csv" 

# Define the Group ID 
$groupId = "your-group-id" 

# Iterate over each member and add them to the group 
foreach ($member in $members) { 
    try{ 
        New-MgGroupMember -GroupId $groupId -DirectoryObjectId $member.memberObjectId 
  	 Write-Host "Added $($member.memberObjectId) to the group."  
    } 
    Catch{ 
        Write-Host "Error adding member $($member.memberObjectId):$($_.Exception.Message)" 
    } 
} 

# Disconnect from Microsoft Graph 
Disconnect-MgGraph 

メンバーを一括で削除する

Import-Module Microsoft.Graph.Groups 

 # Authenticate to Microsoft Graph (you may need to provide your credentials) 
 Connect-MgGraph -Scopes "GroupMember.ReadWrite.All" 

# Import the CSV file 
$members = Import-Csv -Path "C:\path\to\your\file.csv" 

# Define the Group ID 
$groupId = "your-group-id" 

# Iterate over each member and add them to the group 
foreach ($member in $members) { 
    try{ 
        Remove-MgGroupMemberByRef -GroupId $groupId -DirectoryObjectId $member.memberObjectId \
        Write-Host "Removed $($member.memberObjectId) from the group." 
    } 
    Catch{ 
        Write-Host "Error removing member $($member.memberObjectId):$($_.Exception.Message)" 
    } 
} 

# Disconnect from Microsoft Graph 
Disconnect-MgGraph 

デバイス

すべてのデバイスを一括ダウンロードする

Import-Module Microsoft.Graph 

 # Authenticate to Microsoft Graph (you may need to provide your credentials) 
 Connect-MgGraph -Scopes "Device.Read.All" 

 # Get all devices  
 $devices = Get-MgDevice -All |select displayName,deviceId,operatingSystem,operatingSystemVersion,isManaged,isCompliant,mdmAppId,registeredOwners,TrustType 

 # Specify the output CSV file path 
 $outputCsvPath = "C:\\Users\\YourUserName\\Documents\\Devices.csv" 

 $devices| Export-Csv -Path $outputCsvPath -NoTypeInformation 

 Write-Host "Devices exported to $outputCsvPath"  

次のステップ