User Account, Employee Details

63 views
Skip to first unread message

bhi...@appen.com

unread,
Aug 11, 2017, 8:12:42 PM8/11/17
to gshell-discuss
First off, thanks for creating this, so awesome!

I am trying to figure out a way to set the fields found under "Employee Details":

Title, Employee Type, Department, Cost Center.

I haven't been unable to figure it out as of yet and have cruised through the discussion board without much luck.

Spencer Varney

unread,
Aug 12, 2017, 12:01:37 AM8/12/17
to bhi...@appen.com, gshell-discuss
My pleasure! Check out some of the buried object details in the result from Get-GAUser, for instance:

$U = get-gauser SOMEUSER -gauthid DOMAIN.COM
$U.userObject.Organizations

that should give you what you're looking for - at least it does for me! Let me know if that's not the case.

Note - if the user has more than one organization attached to it, they'll all show up here, i think.

--
You received this message because you are subscribed to the Google Groups "gshell-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gshell-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bhi...@appen.com

unread,
Aug 12, 2017, 12:30:35 AM8/12/17
to gshell-discuss, bhi...@appen.com
So, am I correct in that I cannot provide this info during a New-GAUser, but would have to do it via a Set-GAuser after the User exists?

I was able to get the following working:

$user = (Get-GAUser $data.'Email Address').UserObject
$orgObj = New-GAUserOrganizationObj `
-CostCenter $data.'Cost Center' `
-Department $data.Department `
-Title $data.'Employee Title' `
-Description $data.'Employee Type'
$user.Organizations = $orgObj
Set-GAUser -UserKey $data.'Email Address' -UserBody $user

Spencer Varney

unread,
Aug 13, 2017, 10:19:21 PM8/13/17
to bhi...@appen.com, gshell-discuss
Actually, you can, it just takes a little doing - you were on the right track. Unfortunately it means not using the default parameter sets that do things like hashing the password for you and building the objects as required. Also, turns out I need to update some of my code to allow for it in a better way (see after).

To get you started, here is code that works (I've only not tested the password).

$O = New-GAUserOrganizationObj -CostCenter "NewcostCenter" -Department "This their dept" -Location "SomewhereOutThere"
$N = New-GAUserNameObj -FamilyName "Smith" -GivenName "Bob"
$P = "ThisIsPasswordInPlainText"
$B = New-GAUserObj -Organizations $O -Name $N -Password $P -PrimaryEmail "bsmit...@test.sjcny.edu"

New-GAUser -UserBody $B -UserName "ignorethis"

First off, see here to see what fields Google requires in a new account - basically first and last name, password and primary email. Everything else can be added, as long as the required fields are provided. Here I build out the organization object first, then the name object, then the password, and finally add it all in to the body object.

Note: This will send your password via plain-text. If you want to hash it, you'll need to hash the password string and then specify the hash function in the proper $B.hashfunction or using -HashFunction when you build the body. GShell uses the md5 hash by default when you are using the other parameter sets, so if you'd like me to link to the relevant part of the C# code for that let me know. Otherwise Google is your friend, for now.

As I mentioned, my code is a little not great. That's because the -UserName is required for new-gauser no matter what, but if you specify the -Body param it isn't used.  I'll have to fix that. At the very least, could you add a new issue for that and we can start working on getting it fixed.

Down the line we can discuss how better to allow users to include a body while also using things like the built-in password hashing.

Hope that helps!

Cheers,

Spencer
Reply all
Reply to author
Forward
0 new messages