Posted On July 15, 2021

PowerShell: Query Google Account Using GAM

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> PowerShell: Query Google Account Using GAM
$emailAddress='[email protected]'
$field='accounts:last_login_time'

function getGamUser{
    param(
        $emailAddress,
        $field
    )

    $result=try{gam report users user $emailAddress}catch{}
    if($result){
        $headers=$result[0] -split ','
        $index=$headers.IndexOf($field)
        return ($result[1] -split ',')[$index]
    }else{
        write-warning "$emailAddress field $field has not matched anything"
        return $null
    }
}

getGamUser $emailAddress $field

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Setting Trace Logging for MS Dynamics CRM

Function 1: Set CRM Tracing # crmTraceLogSettings.ps1 $traceDirectory="L:\crmTraceLogs" $enable=$false $categories='*:\Verbose' $fileSize=10 $resetIis=$true function setCrmTrace{ param…

Open VPN Client Configuration Fix

OpenVPN client works very well on Windows 7 machines. However, its Windows 10 and Linux…

PowerShell: Execution Policy

This is an example when Windows has an execution policy set as Restricted: PS C:\Users\KimConnect>…