Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-GSGroup Fields parameter cannot be found #63

Closed
WToorenburghIntiveo opened this issue Jun 26, 2018 · 5 comments
Closed

Get-GSGroup Fields parameter cannot be found #63

WToorenburghIntiveo opened this issue Jun 26, 2018 · 5 comments
Assignees
Labels

Comments

@WToorenburghIntiveo
Copy link

Hey there,

I'm trying to use Get-GSGroup with just the Fields parameter to get all the groups in my org with certain fields. I've got version 2.7.0 of PSGSuite, and I'm running on Windows 10 x64 1803 17134.112, with Powershell version 5.1. This is what I'm trying to run:

$Fields = @("Aliases", "Description", "EMail", "Kind", "Name", "Members")
$Groups = Get-GSGroup -Fields $Fields

However, when I run this, Powershell throws an error:

Get-GSGroup : A parameter cannot be found that matches parameter name 'Fields'.
At C:\development\ITTools\Projects\Domain and USMT\ImportGroupsFromGSuite.ps1:4 char:11
+ $Groups = Get-GSGroup -Fields $Fields
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-GSGroup

I should note that I'm running this command using a debugging session in Visual Studio Code with the Powershell extension. I did confirm that this error is thrown in a normal Powershell session as well.

When stepping into the execution, I find that, in the Get-GSGroup definition, the error gets thrown on line 74, which is calling Get-GSGroupListPrivate, and that function doesn't have a Fields parameter. Because Get-GSGroups passes $PSBoundParameters to Get-GSGroupListPrivate, it throws the parameter cannot be found error.

If it's not feasible to have the fields be passed for retreiving all groups, perhaps a more descriptive error would be helpful, as well a note in the docs. Otherwise, I guess this may have been an oversight in the coding process?

Thanks for putting together such an amazing library!

@scrthq scrthq self-assigned this Jun 27, 2018
@scrthq scrthq added the bug label Jun 27, 2018
@scrthq
Copy link
Member

scrthq commented Jun 27, 2018

@WToorenburghEasyMarkit thanks for the catch!! I'm on it!! Should 100% be supported so let me make sure that can happen (or figure out barriers at the very least!)

@scrthq
Copy link
Member

scrthq commented Jun 29, 2018

@WToorenburghEasyMarkit - alright did some digging and found some oddness. The List() request for Groups in the .NET SDK does have a Fields property, but any attempt to use it after applying the fix returns an invalid field error. Checking on the actual API explorer and it doesn't look like their List method allows specification of Fields like the Get method does

That being said, pushing up a fix in v2.8.1 that blocks use of Fields unless specifying a Group as well via parameter set inclusion to prevent further confusing errors, since Google doesn't appear to support it currently with the List method for Groups

Also worth noting: Fields for Google's API's are always mixed camel case, with the first letter always lower case. So your call would need to look something like this otherwise you'll get similar errors (additional corrections on field names):

$Fields = @("nonEditableAliases", "description", "email", "kind", "name", "directMembersCount")
$Groups = Get-GSGroup -Group mytestgroup -Fields $Fields

scrthq added a commit that referenced this issue Jun 29, 2018
scrthq added a commit that referenced this issue Jun 29, 2018
## 2.8.1
 
* Fixed: `Get-GSGroup` failing when using `List` ParameterSet and the `Fields` Parameter ([Issue #63](#63))
@scrthq
Copy link
Member

scrthq commented Jun 29, 2018

deployed!

Also worth noting that the speed difference between specifying a single field vs having it return all fields is negligible, sometimes even taking longer to return a group with a single field vs just returning all fields:

[IPS 6.0.2] >_ Measure-Command {Get-GSGroup $groupName -Fields 'description'}


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 511
Ticks             : 5116080
TotalDays         : 5.92138888888889E-06
TotalHours        : 0.000142113333333333
TotalMinutes      : 0.0085268
TotalSeconds      : 0.511608
TotalMilliseconds : 511.608



[8] [STATUS: SUCCESS IN 0:00:00.5163 AT 23:16:24 ON 2018-06-28]
~
[IPS 6.0.2] >_ Measure-Command {Get-GSGroup $groupName}


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 458
Ticks             : 4580480
TotalDays         : 5.30148148148148E-06
TotalHours        : 0.000127235555555556
TotalMinutes      : 0.00763413333333333
TotalSeconds      : 0.458048
TotalMilliseconds : 458.048



[9] [STATUS: SUCCESS IN 0:00:00.4619 AT 23:16:31 ON 2018-06-28]
~
[IPS 6.0.2] >_

VS

[IPS 6.0.2] >_ Measure-Command {Get-GSGroup $groupName -Fields 'description'}


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 477
Ticks             : 4777180
TotalDays         : 5.52914351851852E-06
TotalHours        : 0.000132699444444444
TotalMinutes      : 0.00796196666666667
TotalSeconds      : 0.477718
TotalMilliseconds : 477.718



[10] [STATUS: SUCCESS IN 0:00:00.4823 AT 23:19:11 ON 2018-06-28]
~
[IPS 6.0.2] >_ Measure-Command {Get-GSGroup $groupName}


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 511
Ticks             : 5111990
TotalDays         : 5.91665509259259E-06
TotalHours        : 0.000141999722222222
TotalMinutes      : 0.00851998333333333
TotalSeconds      : 0.511199
TotalMilliseconds : 511.199



[11] [STATUS: SUCCESS IN 0:00:00.5157 AT 23:19:14 ON 2018-06-28]
~
[IPS 6.0.2] >_

@scrthq scrthq closed this as completed Jun 29, 2018
@WToorenburghIntiveo
Copy link
Author

You are absolutely amazing. Thank you so much for such a quick response, and for making a fantastic PS module!

@scrthq
Copy link
Member

scrthq commented Jun 30, 2018

I'm glad you like it! Thanks again for submitting the issue to let me know about the bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants