Giter Site home page Giter Site logo

Comments (5)

scrthq avatar scrthq commented on June 16, 2024

Hey Cooper,

With the current released version, Get-GSUser is limited to what Google get user API call options are (which necessitate a UserId / primary email). You would need to use Get-GSUserList -Query $query to do what you're looking to do (but it's 100% doable). You'll need to follow Google's User Search syntax for this: https://developers.google.com/admin-sdk/directory/v1/guides/search-users

Here's an example that I just tested with:

Get-GSUserList -Query "name='Nate Ferrell'"

That all being said, v2.0.0 of PSGSuite allows you to leverage Get-GSUser as a one-stop-shop to provide a level of parity with Get-ADUser -Filter $filter if you're familiar with searching for users. Quick example of how this would be done a little closer to expected syntax with the new version:

Get-GSUser -Filter "name -eq 'Nate Ferrell'"

Cheers!

  • Nate

from psgsuite.

cooper avatar cooper commented on June 16, 2024

Great, thanks for the info.

from psgsuite.

cooper avatar cooper commented on June 16, 2024

In your example, for Get-GSUserList, how can I query a user by a variable first and last name that might contain apostrophes/single quotes?

from psgsuite.

scrthq avatar scrthq commented on June 16, 2024

As Google requires string search values to be wrapped in single quotes/apostrophes, you need to escape any apostrophes in your search string with a backslash. You would need to do string replacement in line if you're doing it programmatically to account for this

# Searching for someone with the exact name "John O'Neal"
$name = "John O'Neal"
Get-GSUserList -Query "name='$($name.Replace("'","\'"))'"

If you're just running commands on the fly and not storing the name in a variable:

Get-GSUserList -Query "name='John O\'Neal'"

from psgsuite.

cooper avatar cooper commented on June 16, 2024

Thank you for that. I decided it was faster to download the entire user list at the start of the script and use something like:

$GSAccount = $googleAccounts | Where-Object { $_.name.fullName -eq $stud.Display }

from psgsuite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.