Edit

Share via


Move-AzDataLakeGen2Item

Move a file or directory to another a file or directory in same Storage account.

Syntax

ReceiveManual (Default)

Move-AzDataLakeGen2Item
    [-FileSystem] <String>
    [-Path] <String>
    -DestFileSystem <String>
    -DestPath <String>
    [-Force]
    [-Context <IStorageContext>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ItemPipeline

Move-AzDataLakeGen2Item
    -InputObject <AzureDataLakeGen2Item>
    -DestFileSystem <String>
    -DestPath <String>
    [-Force]
    [-Context <IStorageContext>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Move-AzDataLakeGen2Item cmdlet moves a a file or directory to another a file or directory in same Storage account. This cmdlet only works if Hierarchical Namespace is enabled for the Storage account. This kind of account can be created by run "New-AzStorageAccount" cmdlet with "-EnableHierarchicalNamespace $true".

Examples

Example 1: Move a fold in same Filesystem

Move-AzDataLakeGen2Item -FileSystem "filesystem1" -Path "dir1/" -DestFileSystem "filesystem1" -DestPath "dir3/"
FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group
----                 -----------  ------          ------------         -----------  -----                -----
dir3                 True                         2020-03-13 13:07:34Z rwxrw-rw-    $superuser           $superuser

This command move directory 'dir1' to directory 'dir3' in the same Filesystem.

Example 2: Move a file by pipeline, to another Filesystem in the same Storage account without prompt

Get-AzDataLakeGen2Item -FileSystem "filesystem1" -Path "dir1/file1" | Move-AzDataLakeGen2Item -DestFileSystem "filesystem2" -DestPath "dir2/file2" -Force
FileSystem Name: filesystem2

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group
----                 -----------  ------          ------------         -----------  -----                -----
dir2/file2           False        1024            2020-03-23 09:57:33Z rwxrw-rw-    $superuser           $superuser

This command move file 'dir1/file1' in 'filesystem1' to file 'dir2/file2' in 'filesystem2' in the same Storage account without prompt.

Example 3: Move an item with Sas token

$sas = New-AzStorageContainerSASToken -Name $filesystemName -Permission rdw -Context $ctx

$sasctx = New-AzStorageContext -StorageAccountName $ctx.StorageAccountName -SasToken $sas

Move-AzDataLakeGen2Item -FileSystem $filesystemName -Path $itempath1 -DestFileSystem $filesystemName -DestPath "$($itempath2)$($sas)" -Context $sasctx
FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group
----                 -----------  ------          ------------         -----------  -----                -----
dir2/file1           False        1024            2021-03-23 09:57:33Z rwxrw-rw-    $superuser           $superuser

This first command creates a Sas token with rdw permission, the second command creates a Storage context from the Sas token, the 3rd command moves an item with the Sas token. This example use same Sastoken with rdw permission on both source and destination, if use 2 SAS token for source and destination, source need permission rd, destination need permission w.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Context

Azure Storage Context Object

Parameter properties

Type:IStorageContext
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DestFileSystem

Dest FileSystem name

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DestPath

Dest Blob path

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-FileSystem

FileSystem name

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ReceiveManual
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Force to over write the destination.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

Azure Datalake Gen2 Item Object to move from.

Parameter properties

Type:AzureDataLakeGen2Item
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ItemPipeline
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Path

The path in the specified Filesystem that should be move from. Can be a file or directory In the format 'directory/file.txt' or 'directory1/directory2/'

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ReceiveManual
Position:1
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

AzureDataLakeGen2Item

IStorageContext

Outputs

AzureDataLakeGen2Item