Checking if a user exists

3,670 views
Skip to first unread message

Brett Purcell

unread,
Aug 27, 2018, 4:39:45 PM8/27/18
to GAM for G Suite

Is there any good way in GAM currently to check whether or not an email address exists? I'm using $userExists = (gam info user $emailAddress userview) in PowerShell currently and it works, but it spits out errors any time it runs into a user that doesn't exist and I'd really like to make things a bit cleaner if possible though I'm not seeing any other way to check for it.

Raj Veeravalli

unread,
Aug 27, 2018, 6:59:18 PM8/27/18
to GAM for G Suite
Hi Brett,

I too use "gam info user xyz"

If the address is not valid, the response to the command has the form

User: xyz at domain.name, Does not exist

In DOS %errorlevel% is non-zero when a command executes with errors.
The PowerShell equivalent is $? or $LASTEXITCODE


I am also interested in a better approach if it's available.

Raj

Bradley Stinson

unread,
Aug 27, 2018, 7:16:42 PM8/27/18
to google-ap...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/4553865b-6e7a-4399-b636-823bcfcefb82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

✉ Kevin Melillo

unread,
Aug 28, 2018, 11:23:38 AM8/28/18
to google-ap...@googlegroups.com
I have to agree with Bradley on this one.  If you are searching for an email that exists, then you would want to check groups, and aliases as well.

./gam whatis <email_address> 

It will tell you if it is in use as a group or user or alias, and if it is an alias, what user\group it is assigned to.


For more options, visit https://groups.google.com/d/optout.


--
Kevin Melillo
Electronic Communications Analyst
Information Technology
445 Hoes Lane
Piscataway, NJ 08854

Phone:732-465-6609 | Mobile: 732-609-4331

Brett Purcell

unread,
Aug 28, 2018, 11:59:57 AM8/28/18
to GAM for G Suite
Unfortunately, both whatis and info user return an error when running in PowerShell. They both will populate a variable with the user's information, but they also spit out error text to the console, which is what I'm looking to clean up. And I'm not in this case trying to check groups or anything, I really just want a boolean "true" or "false" to see if a user does exist or not.


On Tuesday, August 28, 2018 at 9:23:38 AM UTC-6, k.melillo wrote:
I have to agree with Bradley on this one.  If you are searching for an email that exists, then you would want to check groups, and aliases as well.

./gam whatis <email_address> 

It will tell you if it is in use as a group or user or alias, and if it is an alias, what user\group it is assigned to.

On Mon, Aug 27, 2018 at 7:16 PM 'Bradley Stinson' via GAM for G Suite <google-ap...@googlegroups.com> wrote:
On Mon, Aug 27, 2018 at 3:59 PM Raj Veeravalli <raj.vee...@jmss.vic.edu.au> wrote:
Hi Brett,

I too use "gam info user xyz"

If the address is not valid, the response to the command has the form

User: xyz at domain.name, Does not exist

In DOS %errorlevel% is non-zero when a command executes with errors.
The PowerShell equivalent is $? or $LASTEXITCODE


I am also interested in a better approach if it's available.

Raj



On Tuesday, 28 August 2018 06:39:45 UTC+10, Brett Purcell wrote:

Is there any good way in GAM currently to check whether or not an email address exists? I'm using $userExists = (gam info user $emailAddress userview) in PowerShell currently and it works, but it spits out errors any time it runs into a user that doesn't exist and I'd really like to make things a bit cleaner if possible though I'm not seeing any other way to check for it.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

+KimNilsson

unread,
Aug 31, 2018, 4:19:22 AM8/31/18
to GAM for G Suite
Ross updated his gam to make the whatis feature a little bit better.

✉ Kevin Melillo

unread,
Aug 31, 2018, 9:15:35 AM8/31/18
to google-ap...@googlegroups.com
I got so caught up in the original question that I forgot why I was asking!  Thanks KimNilsson!

On Fri, Aug 31, 2018 at 4:19 AM +KimNilsson <there.is.no...@gmail.com> wrote:
Ross updated his gam to make the whatis feature a little bit better.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages