Public/Gmail/Get-GSGmailVacationSettings.ps1
function Get-GSGmailVacationSettings { <# .SYNOPSIS Gets Vacation settings .DESCRIPTION Gets Vacation settings .PARAMETER User The user to get the Vacation settings for Defaults to the AdminEmail user .EXAMPLE Get-GSGmailVacationSettings Gets the Vacation settings for the AdminEmail user #> [cmdletbinding()] Param ( [parameter(Mandatory = $false,Position = 0,ValueFromPipelineByPropertyName = $true)] [Alias("PrimaryEmail","UserKey","Mail")] [ValidateNotNullOrEmpty()] [string] $User = $Script:PSGSuite.AdminEmail ) Begin { if ($User -ceq 'me') { $User = $Script:PSGSuite.AdminEmail } elseif ($User -notlike "*@*.*") { $User = "$($User)@$($Script:PSGSuite.Domain)" } $serviceParams = @{ Scope = 'https://www.googleapis.com/auth/gmail.settings.basic' ServiceType = 'Google.Apis.Gmail.v1.GmailService' User = $User } $service = New-GoogleService @serviceParams } Process { try { $request = $service.Users.Settings.GetVacation($User) Write-Verbose "Getting Vacation settings for user '$User'" $request.Execute() | Select-Object @{N = 'User';E = {$User}},* } catch { if ($ErrorActionPreference -eq 'Stop') { $PSCmdlet.ThrowTerminatingError($_) } else { Write-Error $_ } } } } |