Cmdlet
New-OfficeGoogleWorkspaceSession
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:
ServiceAccountDescription
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
- Application name sent with requests.
- -KeyPath String
- Exact service-account JSON key path.
- -MaxRetryCount Int32
- Maximum native retries.
- -RequestTimeoutSeconds Int32
- Per-request timeout.
- -Scope String[]
- Native scope names or full URLs; default authorizes Docs and Sheets with DriveFile.
- -Subject String
- 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.