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

Bash Shell Quick If Then and Case Switch Statements

protocol=udp # or tcp # If-then implementation if [$protocol == udp] then prefix=@ else prefix=@@…

Transfer DHCP Scopes Between Windows Servers

When a new DHCP server is introduced into the system, it's often necessary to configure…

Upgrade from Windows 2008 R2 to 2012 R2

1. Run: f:\support\adprep\adprep /forestprep f:\support\adprep\adprep /domainprep   2. Start Windows setup to upgrade the OS…
Other project: DragonCoin.com