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

Domain Controller Error: Broken DFS Replication

Error message: The DFS Replication service detected that the local path of a replicated folder…

PowerShell: Automating Process of Setting Up a New Windows Machine

# Step -2: Creating a New Virtual Machine # Example A: Hyper-V # Compulsory variables…

PowerShell: Process Watcher

# processWatcher.ps1 # User Input $serviceName='MSCRMAsyncService$maintenance' # Semi-autogen variables $desiredStatus='Running' $environment=($env:computername).substring(0,$env:computername.IndexOf('-')) $reportServer="$environment-SQL01" function checkService($computername=$env:computername,$serviceName,$status='Running'){ #…