Exports directory objects from a Microsoft 365 tenant.
Export-M365DirectoryObjects [-ShowPrereqs] [<CommonParameters>]
Export-M365DirectoryObjects -ConfigNode <String> [-Target <String>] [-Format <String>]
[<CommonParameters>]
Use the Export-M365DirectoryObjects cmdlet to export directory objects
from a Microsoft 365 tenant. Because M365 does not support listing directory objects from the tenant, the results are
limited to cached objects.
See the Notes section for cmdlet requirements.
Export-M365DirectoryObjects -ConfigNode Source -Format Csv >'directory_objects.csv'
This example exports all directory objects from a Microsoft 365 tenant.
The exported data is formatted as CSV
and saved to the file directory_objects.csv.
The config.psd1 configuration node to use.
Type: String
Parameter Sets: Action
Aliases:
Accepted values: Source, Target
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The output type for exported data.
Note that extended properties cannot be serialized into CSV format. When using
-Format Csv, extended properties will display as
System.Collections.Hashtable in the output.
Type: String
Parameter Sets: Action
Aliases:
Accepted values: Csv, Json, Objects
Required: False
Position: Named
Default value: Objects
Accept pipeline input: False
Accept wildcard characters: False
Prints the cmdlet prerequisites.
Type: SwitchParameter
Parameter Sets: Help
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies a mapping target for the exported data. Exported data mapped for a supported target is directly consumable by a corresponding import cmdlet.
To export unmapped data, use -Target None.
Type: String
Parameter Sets: Action
Aliases:
Accepted values: None
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Required PowerShell modules
ExchangeOnlineManagementMicrosoft.Online.SharePoint.PowerShellPnP.PowerShellNote that you must install the Microsoft.Online.SharePoint.PowerShell module using Windows PowerShell
(PowerShell 5.1 or earlier).
Required config.psd1 configurations
M365ClientIdM365ClientSecretM365SharePointDomainM365TenantOptional config.psd1 configurations
M365ClientCertificateM365CloudEnvironmentRequired APIs
Microsoft GraphOffice 365 Exchange OnlineSharePointRequired Microsoft Graph Application scopes
Calendars.ReadDirectory.Read.AllSites.Read.AllRequired Office 365 Exchange Online Application scopes
Exchange.ManageAsAppRequired SharePoint Application scopes
Sites.FullControl.All