< Back

Get-GDriveItemContent

Mon Jan 13, 2020 10:24 pm

NAME Get-GDriveItemContent



SYNOPSIS

Get GoogleDrive Item content





SYNTAX

Get-GDriveItemContent [-ID] <String> [-RevisionID <String>] [-Offset <Int64>] [-Length <Int64>] [-Encoding

<Encoding>] -AccessToken <String> [<CommonParameters>]



Get-GDriveItemContent [-ID] <String> [-RevisionID <String>] [-OutFile <String>] [-Offset <Int64>] [-Length

<Int64>] -AccessToken <String> [<CommonParameters>]



Get-GDriveItemContent [-ID] <String> [-RevisionID <String>] [-Raw] [-Offset <Int64>] [-Length <Int64>]

-AccessToken <String> [<CommonParameters>]





DESCRIPTION

Get GoogleDrive Item content

Content can be returned as string, as byte[] array or saved to file





PARAMETERS

-ID <String>

File ID to return content from



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-RevisionID <String>

File Revision ID to return content from (Version history)



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OutFile <String>

Save content into file path



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Raw [<SwitchParameter>]

Return content as raw byte[] array



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Offset <Int64>

Set Offset from which content will be returned, 0 of not set



Required? false

Position? named

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-Length <Int64>

Set Length of content will be returned, full file if not set



Required? false

Position? named

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-Encoding <Encoding>

Set output encoding if content will be returned as string.

By default used GoodleDrive supplied encoding



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-AccessToken <String>

Access Token for request



Required? true

Position? named

Default value

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



OUTPUTS

string

byte[]

file





NOTES





Author: Max Kozlov



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



PS C:\\># return string with file contents



Get-GDriveItemContent -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0'









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



PS C:\\># return string with file contents in 866 encoding



Get-GDriveItemContent -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0' -Encoding

([Text.Encoding]::GetEncoding(866))









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



PS C:\\># return byte[] with file contents



Get-GDriveItemContent -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0' -Raw









-------------------------- EXAMPLE 4 --------------------------



PS C:\\># save fine content to file



Get-GDriveItemContent -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0' -OutFile D:\\test.txt









-------------------------- EXAMPLE 5 --------------------------



PS C:\\># return string with previous file revision



$revisionId = Get-GDriveItemRevisionList -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0' -AllResults

| `

Select-Object -ExpandProperty revisions | `

Select-Object -Skip 1 -Last 1

# Alternative:

# $revisionId = (Get-GDriveItemRevisionList -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0'

-AllResults).revisions[-2]

Get-GDriveItemContent -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0' -RevisionID $revisionId











RELATED LINKS

Get-GDriveItemProperty

Set-GDriveItemContent

Get-GDriveItemRevisionList

https://developers.google.com/drive/api ... /files/get

https://developers.google.com/drive/api ... isions/get

https://developers.google.com/drive/api ... -downloads