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

Linux: Remediate SSL Weak Cipher Suites

Description The remote host supports the use of SSL ciphers that offer weak encryption. Note:…

Remote Desktop Connection An internal error has occurred.

RDP Error Message:     Resolution: Method 1: Create and apply a self signed certificate…

Using SysPrep To Move Windows Users Directory

Assumptions: Windows 2019 Server Standard ISO is mounted as E:\ D:\Users will be the new…