< Back

Copy-GcsObject

Mon Jan 13, 2020 11:06 pm

NAME Copy-GcsObject



SYNOPSIS

Copies a Google Cloud Storage object to another location.





SYNTAX

Copy-GcsObject -InputObject <Object> [[-DestinationBucket] <string>] [[-DestinationObjectName] <string>] [-Force

<SwitchParameter>] [<CommonParameters>]



Copy-GcsObject [-Bucket <string>] -ObjectName <string> [[-DestinationBucket] <string>] [[-DestinationObjectName]

<string>] [-Force <SwitchParameter>] [<CommonParameters>]





DESCRIPTION

Copies a Google Cloud Storage object to another location The target location may be in the same bucket with a

different name or a different bucket with any name.



If this cmdlet is used when PowerShell is in a Google Cloud Storage Provider location (i.e, the shell's location

starts with gs:\\), then you may not need to supply -Bucket. For example, if the location is gs:\\my-bucket, the

cmdlet will automatically fill out -Bucket with "my-bucket". If -Bucket is still used, however, whatever value

given will override "my-bucket". If the location is inside a folder on Google Cloud Storage, then the cmdlet will

prefix the folder name to the object name.





PARAMETERS

-InputObject <Object>

A Google Cloud Storage object to read from. Can be obtained with Get-GcsObject.



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Bucket <string>

Name of the bucket containing the object to read from. Will also accept a Bucket object.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SourceBucket <string>

Name of the bucket containing the object to read from. Will also accept a Bucket object.



This is an alias of the Bucket parameter.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ObjectName <string>

Name of the object to read from.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SourceObjectName <string>

Name of the object to read from.



This is an alias of the ObjectName parameter.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DestinationBucket <string>

Name of the bucket in which the copy will reside. Defaults to the source bucket.



Required? false

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DestinationObjectName <string>

The name of the copy. Defaults to the name of the source object.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Force <SwitchParameter>

If set, will overwrite existing objects without prompt.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

Google.Apis.Storage.v1.Data.Object

A Google Cloud Storage object to read from. Can be obtained with Get-GcsObject.





OUTPUTS

Google.Apis.Storage.v1.Data.Object





---------- EXAMPLE 1 ----------



PS C:\\> Copy-GcsObject -Bucket "widget-co-logs" -ObjectName "status.txt" -DestinationBucket "another-bucket"



Copy object "status.txt" in bucket "widget-co-logs" to bucket "another-bucket".

---------- EXAMPLE 2 ----------



PS C:\\> cd gs:\\my-bucket

PS gs:\\my-bucket> Copy-GcsObject -ObjectName "status.txt" -DestinationBucket "another-bucket"

-DestinationObjectName "new-name.txt"



Copy object "status.txt" in bucket "my-bucket" to bucket "another-bucket" as "new-name.txt".



RELATED LINKS