User Properties - Phone Number

32 views
Skip to first unread message

robert...@gmail.com

unread,
Jul 27, 2017, 9:59:27 AM7/27/17
to gshell-discuss
I see that a lot of the user-properties commands are deprecated. (Get-GAUserProperty)

Is there an alternative to grab a users phone number?

Spencer Varney

unread,
Jul 28, 2017, 12:02:58 PM7/28/17
to robert...@gmail.com, gshell-discuss
Hey, sorry for the delayed response. While the cmdlets are depreciated, the functionality still exists - it was just that the way gShell was going about it that was bad. I guess I should probably update the docs further to point to what SHOULD be used, and also fix  the markup so all the hashtags aren't showing. So much to do...

Quickly testing it out, I believe you should be able to get any phone numbers through Get-GAUser. Just drill down in to the user object, and then the phones object:
(Get-GAUser someuser).UserObject.phones

Does that work?

For future reference, setting it is a little more convoluted (but keep in mind this is just wrapping the Google APIs to keep things as open and flexible as possible for  you). You have to grab the UserObject in to a variable, create a new user phone object, use that to update the phones object within the userobject, and then push that back to the server as the 'updated' object. It'd look something like this, if you wanted to wrap it in a function for shiggles:

function Set-GAUserPhone ([string]$UserName, [string]$PhoneNumber, [string]$Type, [bool]$IsPrimary) {
  $U = (Get-GAUser $UserName).UserObject
  $P = New-GAUserPhoneObj -value $PhoneNumber -type $Type -primary $IsPrimary
  $U.Phones = $P
  Set-Gauser -UserKey $UserName -UserBody $U
}

Set-GAUserPhone SomeUser "1-234-567-8910" "other" $true

Regards,

Spencer

On Thu, Jul 27, 2017 at 9:59 AM <robert...@gmail.com> wrote:
I see that a lot of the user-properties commands are deprecated. (Get-GAUserProperty)

Is there an alternative to grab a users phone number?

--
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.

Rob Brown

unread,
Jul 28, 2017, 2:22:37 PM7/28/17
to Spencer Varney, gshell-discuss
That first line works perfectly!

We have an on-site door system that reads the "pager" field in AD for the users HID card, so I am writing a script that syncs my Google Apps Directory to AD.  I had everything done but syncing the phone field to the pager field.
This would have been much easier if Google had a GAD->AD sync, but they seem to only offer AD->GAD.

Thanks again or the quick response!

To unsubscribe from this group and stop receiving emails from it, send an email to gshell-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages