Note: PowerShell integration requires a ShareGate Migrate Pro or Enterprise subscription. It is not available on the Essentials plan.
Command
Import-Document
Description
The command to import documents and folders from a file share to a SharePoint library.
Note: Since Insane mode is used by default (unless -NormalMode is specified), the command waits for the Microsoft 365 Azure import to complete before returning. Use -NoWaitForImportCompletion to return immediately after local processing instead; in that case, the returned result is provisional (the import isn't reflected in it yet). Use Wait-ImportCompletion, or keep the current PowerShell session running, to know when the import actually finishes. The previous -WaitForImportCompletion switch is now deprecated, since waiting for completion is the default behavior again.
Tips:
To learn how to adapt your
Import-Documentscript to perform an incremental migration, see Run an incremental migration in PowerShell.To learn about copy options in your scripts, see Copy options in PowerShell.
To learn how to import file share content to many OneDrives, see Import from file share to OneDrive for Business with PowerShell.
Examples
Run a pre-check before importing all documents.
$dstSite = Connect-Site -Url "http://myfarm1/sites/mydestinationsite"
$dstList = Get-List -Name "mydstlib" -Site $dstSite
Import-Document -SourceFolder "\\mysharedrive\documentsToImport\" -DestinationList $dstList -WhatIf
Import all documents from a file share to a SharePoint library.
Import-Document -SourceFolder "\\mysharedrive\documentsToImport\" -DestinationList $dstList
Import documents using a property template.
Import-Document -SourceFolder "\\mysharedrive\documentsToImport\" -DestinationList $dstList -TemplateName "mypropertytemplate"
Import documents into a specific folder at the destination.
Import-Document -SourceFolder "\\mysharedrive\documentsToImport\" -DestinationList $dstList -DestinationFolder "MyFolder/MySubFolder"
Note: Using -SourceFolder will migrate the content of your folder, but not the folder itself. To migrate your folder and its content instead, you can use -SourceFilePath. See the example below.
Import specific files by path.
Import-Document -DestinationList $dstList -SourceFilePath "\\mysharedrive\documentsToImport\Document1.txt","\\mysharedrive\Folder\Document2.txt"
Note: -SourceFilePath can be a file or folder.
Import specific files by path into a destination folder.
Import-Document -DestinationList $dstList -SourceFilePath "\\mysharedrive\documentsToImport\Document1.txt","\\mysharedrive\Folder\Document2.txt" -DestinationFolder "MyDestinationFolder"
Import documents using an Excel or CSV file for metadata.
Import-Document -DestinationList $dstList -ExcelFilePath "c:\Users\myUser\Desktop\myExcelFile.xslx"
Note: Use this example to import your documents based on an Excel spreadsheet.
Import documents without waiting for the Microsoft 365 Azure import to complete, then use Wait-ImportCompletion to know when it's finished.
$dstSite = Connect-Site -Url "http://myfarm1/sites/mydestinationsite"
$dstList = Get-List -Name "mydstlib" -Site $dstSite
Import-Document -SourceFolder "\\mysharedrive\documentsToImport\" -DestinationList $dstList -NoWaitForImportCompletion
Wait-ImportCompletion
Syntax
Import-Document
-DestinationList <List>
-SourceFolder <Uri>
[-TemplateName <String>]
[-DestinationFolder <Uri>]
[-NormalMode <SwitchParameter>]
[-NoWaitForImportCompletion <SwitchParameter>]
[-WhatIf <SwitchParameter>]
[-CopySettings <CopySettings>]
[-MappingSettings <MappingSettings>]
[-TaskName <String>]
Import-Document
-DestinationList <List>
-SourceFolder <Uri>
-Template <PropertyTemplate>
[-DestinationFolder <Uri>]
[-NormalMode <SwitchParameter>]
[-NoWaitForImportCompletion <SwitchParameter>]
[-WhatIf <SwitchParameter>]
[-CopySettings <CopySettings>]
[-MappingSettings <MappingSettings>]
[-TaskName <String>]
Import-Document
-DestinationList <List>
-Template <PropertyTemplate>
-SourceFilePath <Uri[]>
[-SourceFolder <Uri>]
[-DestinationFolder <Uri>]
[-NormalMode <SwitchParameter>]
[-NoWaitForImportCompletion <SwitchParameter>]
[-WhatIf <SwitchParameter>]
[-CopySettings <CopySettings>]
[-MappingSettings <MappingSettings>]
[-TaskName <String>]
Import-Document
-DestinationList <List>
-SourceFilePath <Uri[]>
[-SourceFolder <Uri>]
[-TemplateName <String>]
[-DestinationFolder <Uri>]
[-NormalMode <SwitchParameter>]
[-NoWaitForImportCompletion <SwitchParameter>]
[-WhatIf <SwitchParameter>]
[-CopySettings <CopySettings>]
[-MappingSettings <MappingSettings>]
[-TaskName <String>]
Import-Document
-DestinationList <List>
-ExcelFilePath <String>
[-TemplateName <String>]
[-DestinationFolder <Uri>]
[-NormalMode <SwitchParameter>]
[-NoWaitForImportCompletion <SwitchParameter>]
[-WhatIf <SwitchParameter>]
[-CopySettings <CopySettings>]
[-MappingSettings <MappingSettings>]
[-TaskName <String>]
Import-Document
-DestinationList <List>
-Template <PropertyTemplate>
-ExcelFilePath <String>
[-DestinationFolder <Uri>]
[-NormalMode <SwitchParameter>]
[-NoWaitForImportCompletion <SwitchParameter>]
[-WhatIf <SwitchParameter>]
[-CopySettings <CopySettings>]
[-MappingSettings <MappingSettings>]
[-TaskName <String>]
Parameters
-CopySettings <CopySettings>
Specifies the copy settings.
Required? | False |
Default value | None |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-DestinationFolder <Uri>
Specifies the folder path at the destination. Note: This parameter cannot be used to create new folders at the destination.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-DestinationList <List>
Specifies the destination list.
Required? | True |
Default value | None |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-ExcelFilePath <String>
Specifies the path of the file used for metadata. Supported formats are Excel and CSV.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | TemplateExcelFilePath, TemplateNameExcelFilePath |
Aliases | None |
-NormalMode <SwitchParameter>
Specifies that the normal mode should be used.
Note: Insane mode is always used by default in PowerShell.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-NoWaitForImportCompletion <SwitchParameter>
Specifies that the command returns after local processing without waiting for the Azure Insane mode import to complete.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-SourceFilePath <Uri[]>
Specifies the source file path.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | TemplateSourceFilePath, TemplateNameSourceFilePath |
Aliases | None |
-SourceFolder <Uri>
Specifies the folder path at the source.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | Default, Template, TemplateSourceFilePath, TemplateNameSourceFilePath |
Aliases | None |
-TaskName <String>
Specifies a name for the task.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-Template <PropertyTemplate>
Specifies the property template. To use the built-in "Full copy" template, do not specify this parameter.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | Template, TemplateSourceFilePath, TemplateExcelFilePath |
Aliases | None |
-TemplateName <String>
Specifies the property template to use by its name. You can use ShareGate to configure property templates for the specified list (see Import Property Mapping or New Property Template). To use the built-in "Full copy" template, do not specify this parameter.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | Default, TemplateNameSourceFilePath, TemplateNameExcelFilePath |
Aliases | None |
-WhatIf <SwitchParameter>
Specifies that a pre-check will be executed instead of a migration. For more information, see Run a Pre-Check in PowerShell.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
