< Back

Read-GcsObject

Mon Jan 13, 2020 11:34 pm

NAME Read-GcsObject



SYNOPSIS

Read the contents of a Cloud Storage object.





SYNTAX

Read-GcsObject [[-Bucket] <string>] [-ObjectName] <string> [[-OutFile] <string>] [-Force <SwitchParameter>]

[<CommonParameters>]



Read-GcsObject -InputObject <Object> [-OutFile <string>] [-Force <SwitchParameter>] [<CommonParameters>]





DESCRIPTION

Reads the contents of a Cloud Storage object. By default the contents will be written to the pipeline. If the

-OutFile parameter is set, it will be written to disk instead.



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

-Bucket <string>

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



Required? false

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ObjectName <string>

Name of the object to read.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InputObject <Object>

The Google Cloud Storage object to read.



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Object <Object>

The Google Cloud Storage object to read.



This is an alias of the InputObject parameter.



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-OutFile <string>

Local file path to write the contents to.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Force <SwitchParameter>

Force the operation to succeed, overwriting any local files.



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

The Google Cloud Storage object to read.





OUTPUTS

System.String





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



PS C:\\> Read-GcsObject -Bucket "widget-co-logs" -ObjectName "log-000.txt" `

>> -OutFile "C:\\logs\\log-000.txt"



Write the objects of a Storage Object to local disk at "C:\\logs\\log-000.txt".

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



PS C:\\> Read-GcsObject -Bucket "widget-co-logs" -ObjectName "log-000.txt" | Write-Host



Returns the storage object's contents as a string.

---------- EXAMPLE 3 ----------



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

PS gs:\\my-bucket> Read-GcsObject -ObjectName "log-000.txt" | Write-Host



Returns contents of the storage object "log-000.txt" in bucket "my-bucket" as a string.



RELATED LINKS