Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

New-OfficeGoogleWorkspaceSession

Module
PSWriteOffice
Inputs
None
Outputs
OfficeIMO.GoogleWorkspace.GoogleWorkspaceSession

Creates a native Google Workspace session from a service-account key.

Syntax

New-OfficeGoogleWorkspaceSession
[-ApplicationName <String>]
[-KeyPath] <String>
[-MaxRetryCount <Int32>]
[-RequestTimeoutSeconds <Int32>]
[-Scope <String[]>]
[-Subject <String>]
[<CommonParameters>]
#
Parameter set: ServiceAccount

Description

Authenticates the requested scopes through the native JWT credential source. The returned session owns no browser or persistent token store. Dispose its CredentialSource when finished. Service-account PEM import requires PowerShell 7.4 or newer.

Examples

Create a delegated reporting session.

$session = New-OfficeGoogleWorkspaceSession -KeyPath ./Secrets/reporting.json -Subject [email protected] -Scope Documents,DriveFile
try { Export-OfficeWordGoogleDocument -Path ./Report.docx -Session $session } finally { $session.CredentialSource.Dispose() }

Parameters

-ApplicationName String optional
Application name sent with requests.
-KeyPath String requiredposition: 0
Exact service-account JSON key path.
-MaxRetryCount Int32 optional
Maximum native retries.
-RequestTimeoutSeconds Int32 optional
Per-request timeout.
-Scope String[] optional
Native scope names or full URLs; default authorizes Docs and Sheets with DriveFile.
-Subject String optional
Delegated user; omission acts as the service account itself.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.