Coder Social home page Coder Social logo

scrt-hq / psgsuite Goto Github PK

View Code? Open in Web Editor NEW
233.0 27.0 71.0 24.95 MB

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities

Home Page: https://psgsuite.io/

License: Apache License 2.0

PowerShell 100.00%
google powershell powershell-modules powershell-adminscripts google-api google-cloud google-drive admin-tools

psgsuite's Introduction

PSGSuite

PSGSuite 2.0.0 released!

Azure Pipelines      Discord - Chat      Slack - Chat      Gitter - Chat

Codacy      PowerShell Gallery      GitHub Releases      GitHub Releases


Documentation

Check out PSGSuite.io for PSGSuite documentation, including initial setup help as well as function help!

Contributing

Interested in helping out with PSGSuite development? Please check out our Contribution Guidelines!

Building the module locally to test changes is as easy as running the build.ps1 file in the root of the repo. This will compile the module with your changes and import the newly compiled module at the end by default.

Want to run the Pester tests locally? Pass Test as the value to the Task script parameter like so:

.\build.ps1 -Task Test

Code of Conduct

Please adhere to our Code of Conduct when interacting with this repo.

License

Apache 2.0

Changelog

Full CHANGELOG here


2.0.0 - Changes

New Functionality

  • PowerShell Core support for cross-platform functionality
  • P12 Keys (service accounts) and client_secrets.json (OAuth) are both now supported
  • All Drive functions now support Team Drives
  • Get-GSGmailMessage can now save message attachments to a local path
  • File uploads to Drive are now supported (including recursive folder uploads!)

Breaking Changes in 2.0.0

Gmail Delegation Management Removed

The Gmail API does not yet support handling inbox delegation. The functionality addition has been pushed back again until Q3 of 2018. Once the Gmail API supports inbox delegation, those functions will be added.

Delegation functions have been re-added to PSGSuite as of v2.4.0! Update now to get all the goodness of v2 + delegation commands!

Functions Removed

Please note that not all functions were ported to PSGSuite 2.0.0 due to restrictions within the .NET SDK and deprecated API calls. Here is the list of functions no longer existing in PSGSuite as of 2.0.0:

  • Get-GSToken: no need for this as the keys are being consumed by Googles Auth SDK directly now, which makes Access/Refresh tokens non-existent for P12 Key service accounts and token management is handled automatically
  • Revoke-GSToken: same here, no longer needed due to auth service changes
  • Start-PSGSuiteConfigWizard: no longer supported as WPF is not compatible outside of Windows

Functions Aliased

All other functions are either intact or have an alias included to support backwards compatibility in scripts. Full list of aliases:

Alias Maps To
Add-GSDriveFilePermissions Add-GSDrivePermission
Export-PSGSuiteConfiguration Set-PSGSuiteConfig
Get-GSCalendarEventList Get-GSCalendarEvent
Get-GSCalendarResourceList Get-GSResourceList
Get-GSDataTransferApplicationList Get-GSDataTransferApplication
Get-GSDriveFileInfo Get-GSDriveFile
Get-GSDriveFilePermissionsList Get-GSDrivePermission
Get-GSGmailDelegates Get-GSGmailDelegate
Get-GSGmailFilterList Get-GSGmailFilter
Get-GSGmailLabelList Get-GSGmailLabel
Get-GSGmailMessageInfo Get-GSGmailMessage
Get-GSGmailSendAsSettings Get-GSGmailSendAsAlias
Get-GSGmailSignature Get-GSGmailSendAsAlias
Get-GSGroupList Get-GSGroup
Get-GSGroupMemberList Get-GSGroupMember
Get-GSMobileDeviceList Get-GSMobileDevice
Get-GSOrganizationalUnitList Get-GSOrganizationalUnit
Get-GSOrgUnit Get-GSOrganizationalUnit
Get-GSOrgUnitList Get-GSOrganizationalUnit
Get-GSOU Get-GSOrganizationalUnit
Get-GSResourceList Get-GSResource
Get-GSShortURLInfo Get-GSShortURL
Get-GSTeamDrive Get-GSDrive
Get-GSTeamDrivesList Get-GSDrive
Get-GSUserASPList Get-GSUserASP
Get-GSUserLicenseInfo Get-GSUserLicense
Get-GSUserLicenseList Get-GSUserLicense
Get-GSUserList Get-GSUser
Get-GSUserSchemaInfo Get-GSUserSchema
Get-GSUserSchemaList Get-GSUserSchema
Get-GSUserTokenList Get-GSUserToken
Import-PSGSuiteConfiguration Get-PSGSuiteConfig
Move-GSGmailMessageToTrash Remove-GSGmailMessage
New-GSCalendarResource New-GSResource
Remove-GSGmailMessageFromTrash Restore-GSGmailMessage
Set-PSGSuiteDefaultDomain Switch-PSGSuiteConfig
Switch-PSGSuiteDomain Switch-PSGSuiteConfig
Update-GSCalendarResource Update-GSResource
Update-GSGmailSendAsSettings Update-GSGmailSendAsAlias
Update-GSSheetValue Export-GSSheet

Most recent changes

Full CHANGELOG here

2.36.4 - 2020-03-20

  • Issue #270
    • Corrected inaccurate warning that no licenses were found for a user when using the CheckAll switch on Get-GSUserLicense.

2.36.3 - 2020-03-20

  • Issue #270
    • Added CheckAll switch parameter to Get-GSUserLicense
    • Updated User parameter aliases for all *-GSUserLicense functions to include UserId for better pipeline support.
  • Miscellaneous
    • Updated GitHub Release section in psake.ps1 to POST the release to the Org URL due to failures.

2.36.2 - 2020-03-02

  • Issue #263
    • Cleaned up decryption logic for encrypted config.

2.36.1 - 2020-03-02

  • Issue #263
    • Fixed [SecureString] decryption on Unix machines running PowerShell 7 (found additional bugs)
    • Migrated private Encrypt and Decrypt to EncryptionHelpers.ps1 in the Private folder to allow a single place to update.

2.36.0 - 2020-02-28

  • PR #255 - Thanks, @FISHMANPET!
    • Added support for [ScriptBlock] values on the config, allowing you to provide a script to run that will pull in a configuration value (vs embedded the value directly on the config)
  • PR #255 - Thanks, @vaskotoo!
    • Added support for an array of Users on Get-GSGmailMessageList
  • PR #261 - Thanks, @Foggy2!
    • Added support for all license types including undocumented ones.
    • Closed out Issue #252 as well.
  • PR #262 - Thanks, @nwls-hermesj!
    • Added support for pipeline input of Drive file objects to Remove-GSDriveFile.
  • Issue #256
    • Cleaned up docs on Send-GSChatMessage.
  • Issue #258
    • Removed URL Shortener functions due to Google deprecation.
  • Issue #263
    • Fixed [SecureString] decryption on Unix machines running PowerShell 7
  • Miscellaneous
    • Removed the Tasks API functions. Google has not pushed an update to the Tasks .NET SDK in over 2 months, so it is now behind the current release versions of the core Google.Apis assemblies, resulting in failure to import.

psgsuite's People

Contributors

devblackops avatar dwrusse avatar fishmanpet avatar foggy2 avatar gitter-badger avatar gsa-hub avatar mattwoolnough avatar nate-ferrell avatar nferrell avatar nwls-hermesj avatar scrthq avatar sguilbault-sherweb avatar vaskotoo avatar wjurecki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psgsuite's Issues

Export-GSDriveFile : Exception calling "Create"

When I try to use the Export-GSDriveFile, I am getting the following error.

Export-GSDriveFile : Exception calling "Create" with "1" argument(s): "Access to the path 'c:\temp' is denied."

I can create files within this folder. I tried passing in a different folder with the -OutFilePath argument and I still get the same response. I also tried to manually run this line which is where it is failing:
$stream = [System.IO.File]::Create($OutFilePath)

This line doesn't appear to work when passing in a directory. It appears to want a full file path, but that isn't what is being passed in when using the Export-GSDriveFile function and it complains if I try to pass in a file:

Export-GSDriveFile : Cannot validate argument on parameter 'OutFilePath'. The "(Get-Item $_).PSIsContainer" validation script for the
argument with value "C:\temp\test\cheese.csv" did not return a result of True. Determine why the validation script failed, and then try
the command again.

This is on Windows 10 1803

Any ideas?

Send-GmailMessage fails to build MimeMessage

Error:

Send-GmailMessage -Subject testing -Body 'Testing more' -To nate@scrthq.com
New-MimeMessage : Cannot process argument transformation on parameter 'Body'. Cannot convert value to type
System.String.
At line:110 char:32
+         $raw = New-MimeMessage @messageParams | Convert-Base64 -From  ...
+                                ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-MimeMessage], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MimeMessage

Send-GmailMessage : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
Recipient address required [400]
Errors [
        Message[Recipient address required] Location[ - ] Reason[invalidArgument] Domain[global]
]
"
At line:1 char:1
+ Send-GmailMessage -Subject testing -Body 'Testing more' -To nate@scrt ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Send-GmailMessage

Fix to come in 2.1.6

[Issue] Send-GmailMessage is fitting message body to a set width

Describe the bug
Send-GmailMessage is fitting the body of the message to a specific width instead of sending the text the way it was passed into the function.

To Reproduce
Steps to reproduce the behavior:

  1. Use Send-GmailMessage and make sure to have enough text in a line to go beyond the set width.

Expected behavior
I would expect the Send-GmailMessage to send the message body as I pass it. It appears to be setting the message to a specific width. Here are two screenshots. One showing the message with the full width in GMail and the other showing it shrunk when sending it using Send-GMailMessage.

fullmessage
shrunkmessage

[Feature Request] Ability to switch configs per command

Hey guys! Do you all feel it would be beneficial to add a -ConfigName parameter to the all of the functions? This would allow you to run a command using a specific config for just that command without having to load the entire config then switch back after.

This (current):

Import-Module PSGSuite
Get-GSUser # This pulls the Admin user of the default config 'domain1'
Switch-PSGSuiteConfig domain2
Get-GSUser # This pulls the Admin user of the config 'domain2'
Switch-PSGSuiteConfig domain1
Get-GSUser # This again pulls the Admin user of the default config 'domain1'

VS this (proposed):

Import-Module PSGSuite
Get-GSUser # This pulls the Admin user of the default config 'domain1'
Get-GSUser -ConfigName domain2 # This pulls the Admin user of the config 'domain2'
Get-GSUser # This again pulls the Admin user of the default config 'domain1' since domain2 was only used due to the -ConfigName parameter

Thoughts?


[Poll] Would you like automated module update checking?

Hey y'all!

Just curious, would it be useful to have built in update checks for PSGSuite?

The goal with this would be to allow you to get a notification when there is a new version of PSGSuite available on the PowerShell Gallery, either on module load or when running a custom function built specifically for update checking.

Choose your preference below!



Please note: This would only tell you if a newer version of PSGSuite is available on the PowerShell Gallery, it would NOT update PSGSuite for you (so no risk of introducing potentially breaking changes in existing scripts).

[Bug] Add-GSDrivePermission fails when transferring ownership

Describe the bug
Transferring ownership of Drive files fails due to the TransferOfOwnership parameter being named that instead of TransferOwnership. This causes the $request object to not see it as a property to add and subsequently ignores it.

This should work:

Add-GSDrivePermission -User $from -FileId $id -Role Owner -Type User -EmailAddress $to -SendNotificationEmail -TransferOfOwnership

but currently throws an error stating that TransferOwnership needs to be set when setting a new user as Owner.

Environment (please complete the following information):

  • OS: Windows 10 1803, macOS
  • PowerShell Version: All
  • PSGSuite Version: 2.13.0

Upgrade to PSGSuite 2.1.5

I am trying to upgrade to PSGSuite 2.1.5. I extracted the .zip from the releases page, but now when I try to use any of the cmdlets, it says the required module 'Configuration' is not loaded. So, I checked the Initial Setup guide to see how to re-configure. Guide says to use Set-PSGSuiteConfig, but when I try to do so, it says: the command was found in the PSGSuite module, but the module could not be loaded (because it can't load the Configuration). I am guessing I skipped a step somewhere...?
psgsuite

Get-GSGroupMemberListPrivate fails with 0 members in group

On line 46 of Get-GSGroupMemberListPrivate.ps1, I would recommend to do this:

if ($null -ne $result.MembersValue) { $result.MembersValue | Add-Member -MemberType NoteProperty -Name 'Group' -Value $Id -PassThru | Add-Member -MemberType ScriptMethod -Name ToString -Value {$this.Email} -PassThru -Force }

Otherwise the Add-Member will fail with you do this on a group with 0 members.

Error when using -CalendarID with Get-GSCalendarEventList

Get-GSCalendarEventList : 'CalendarID' is a ReadOnly property.
At line:1 char:1
+ Get-GSCalendarEventList -CalendarID pnmac.com_seboiq7mlkcodn0apvaevvc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [Get-GSCalendarEventList], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException,Get-GSCalendarEventList

[NEED HELP] Update-GSSheetValue: Value formatting issues for Body.Data in 2.0.0

What's happening:

PSGSuite 1.2.1 uses REST API calls and JSON to build the Body payload, which allows pretty loose type constraints for values; a simple array of arrays in standard PowerShell works great (i.e. @(@('Name','Age'),@('Nate','30')). The issue with doing this via the Sheets .NET SDK is that it's reliant on exact type match and the Values property of the ValueRange object is looking for the following type:

System.Collections.Generic.IList < System.Collections.Generic.IList < object > >

Link to ValueRange documentation from Google: https://developers.google.com/resources/api-libraries/documentation/sheets/v4/csharp/latest/classGoogle_1_1Apis_1_1Sheets_1_1v4_1_1Data_1_1ValueRange.html

Excerpt from documentation describing the Values property:

The data that was read or to be written. This is an array of arrays, the outer array representing all the data and each inner array representing a major dimension. Each item in the inner array corresponds with one cell.

For output, empty trailing rows and columns will not be included.

For input, supported value types are: bool, string, and double. Null values will be skipped. To set a cell to an empty value, set the string value to an empty string.

Sample code to replicate the issue and refactor to get working:

This is where I need help!

#region: Set sample variables
$Append = $false
$Array = @()
$Array += [PSCustomObject]@{
    Name = 'Nate'
    Age = '30'
    Location = 'Texas'
}
$Array += [PSCustomObject]@{
    Name = 'John'
    Age = '25'
    Location = 'California'
}
#endregion: Set sample variables


$values = New-Object System.Collections.Generic.List``1[System.Object]

if (!$Append) {
    $propArray = New-Object System.Collections.Generic.List``1[System.Object]
    $Array[0].PSObject.Properties.Name | ForEach-Object {
        $propArray.Add($_)
    }
    $values.Add([System.Collections.Generic.List``1[System.Object]]$propArray)
}
foreach ($object in $Array) {
    $valueArray = New-Object System.Collections.Generic.List``1[System.Object]
    $object.PSobject.Properties.Value | ForEach-Object {
        $valueArray.Add($_)
    }
    $values.Add([System.Collections.Generic.List``1[System.Object]]$valueArray)
}
$bodyData = (New-Object 'Google.Apis.Sheets.v4.Data.ValueRange' -Property @{
    Range = $Range
    MajorDimension = 'ROWS'
})

$bodyData.Values = $values

One of the errors when attempting to build the object:

New-Object : The value supplied is not valid, or the property is read-only. Change the value, and
then try again.
At line:1 char:14
+ ... bodyData = (New-Object 'Google.Apis.Sheets.v4.Data.ValueRange' -Prope ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-Object], Exception
    + FullyQualifiedErrorId : SetValueException,Microsoft.PowerShell.Commands.NewObjectCommand

Another attempt and another error:

#region: Set sample variables
$Append = $false
$Array = @()
$Array += [PSCustomObject]@{
    Name = 'Nate'
    Age = '30'
    Location = 'Texas'
}
$Array += [PSCustomObject]@{
    Name = 'John'
    Age = '25'
    Location = 'California'
}
#endregion: Set sample variables

$Values = [System.Collections.Generic.List[System.Collections.Generic.List[Object]]]::new()
if (!$Append) {
    $propArray = [System.Collections.Generic.List[Object]]::new()
    $Array[0].PSObject.Properties.Name | ForEach-Object {
        $propArray.Add($_)
    }
    $values.Add($propArray)
}
foreach ($object in $Array) {
    $valueArray = [System.Collections.Generic.List[Object]]::new()
    $object.PSobject.Properties.Value | ForEach-Object {
        $valueArray.Add($_)
    }
    $values.Add($valueArray)
}

$bodyData = (New-Object 'Google.Apis.Sheets.v4.Data.ValueRange' -Property @{
    Range = $Range
    MajorDimension = 'ROWS'
})

$bodyData.Values = $values




Exception setting "Values": "Cannot convert the "System.Collections.Generic.List`1[System.Collections.Generic.List`1[System.Object]]" value of type
"System.Collections.Generic.List`1[[System.Collections.Generic.List`1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]]" to type "System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[System.Object]]"."
At line:37 char:1
+ $bodyData.Values = $values
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

How to get list of groups for a user?

Is there an easy way to get a list of groups to which a user belongs? My script uses job title/other fields in an external source to determine the appropriate groups for the user, then add/remove the user from the appropriate groups.

Get-GSGmailMessage -Id $Id -ParseMessage broken on non-Windows OS

Read-MimeMessage is writing to the $env:TEMP folder when parsing the message. Needs to be converted to a stream instead of a local file, which will fix this issue as well as boost performance when choosing to parse the message as well. Facing issue personally in macOS 10.13.4.

Add-GSDriveFilePermissions to share public - 'FileID' is ReadOnly property error

When using the following command:

Add-GSDriveFilePermissions -FileId "<Redacted FileID>" -type Anyone -Role Reader

I get the following error:

Add-GSDriveFilePermissions : 'FileId' is a ReadOnly property.
At line:1 char:1
+ Add-GSDriveFilePermissions -FileId "[redacted FileID]"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Add-GSDrivePermission

Adding custom schemas to users

Nate,

I appreciate how quickly you were able to add the ability to set custom schemas and publish the changes to PowerShell Gallery! I am getting an error when trying to set one, though. I am probably just missing something:

[fesscript]: PS C:\Users\mcooper\Documents> Update-GSUser mcooper -CustomSchemas @{ Frontier_Private_IDs = @{ Employee_Number = 4097 } }
Update-GSUser : Cannot index into a null array.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Update-GSUser

[fesscript]: PS C:\Users\mcooper\Documents> Update-GSUser mcooper -CustomSchemas @{ Frontier_Private_IDs = @{ Employee_Number = "4097" } }
Update-GSUser : Cannot index into a null array.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Update-GSUser

[fesscript]: PS C:\Users\mcooper\Documents> Update-GSUser mcooper -CustomSchemas @{ "Frontier Private IDs" = @{ "Employee Number" = "4097" } }
Update-GSUser : Cannot index into a null array.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Update-GSUser

The schema group is called "Frontier Private IDs" with attributes "Student Number" and "Employee Number." I noticed when querying a user with Get-GSUser, the spaces are replaced with underscores, but I can't get it to work either way.

Get-GSToken : 401 - Unauthorized: invalid_grant / Invalid JWT

I'm getting this error with the version of the module from the PSGallery.

PS version:

Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
PSVersion                      5.1.15063.674                                                                                                                                                                                                                                                                
PSEdition                      Desktop                                                                                                                                                                                                                                                                      
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                                                                      
BuildVersion                   10.0.15063.674                                                                                                                                                                                                                                                               
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                                                                              
WSManStackVersion              3.0                                                                                                                                                                                                                                                                          
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                                                                          
SerializationVersion           1.1.0.1  

Solution, in Get-GStoken, line 53-54, for iat and exp, we need only the first ten digits:

    exp = ("$expiryDate".Substring(0,10))
    iat = ("$createDate".Substring(0,10))

Remove external IDs

Hi,

I cannot figure out how to remove external IDs from a user. I only have one external ID set, so the goal is to clear them all. I have tried things like:

Update-GSUser someone -ExternalIds $null
Update-GSUser someone -ExternalIds @()

but neither do the trick.

Get-GSGroup Fields parameter cannot be found

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!

PSGSuite v2.0.0 - Development / Testing

Issue to track development and testing of PSGSuite v2.0.0

Remaining TODO's

Functions To Convert/Build

Possible breaking changes on Gmail Delegate functions due to Google deprecating the Email Settings API but still not supporting Inbox Delegation in the Gmail API

Function Conversion New Complete
Add-GSGmailDelegate* ✔️ ❗️
Add-GSGmailFilter ✔️ ✔️
Get-GSGmailDelegates* ✔️ ❗️
Get-GSGmailFilterList ✔️ ✔️
Get-GSGmailLabelList ✔️ ✔️
Remove-GSGmailDelegate* ✔️ ❗️
Remove-GSGmailFilter ✔️ ✔️
Add-GSDriveFilePermissions ✔️ ✔️
Clear-GSSheet ✔️ ✔️
Copy-GSDriveFile ✔️ ✔️
Copy-GSSheet ✔️ ✔️
Get-GSDriveFile ✔️ ✔️
Get-GSDriveFileInfo ✔️ ✔️
Get-GSDriveFileList ✔️ ✔️
Get-GSDriveFilePermissionsList ✔️ ✔️
Get-GSSheetInfo ✔️ ✔️
Get-GSTeamDrive ✔️ ✔️
Get-GSTeamDrivesList ✔️ ✔️
Import-GSSheet ✔️ ✔️
New-GSDriveFile ✔️ ✔️
New-GSSheet ✔️ ✔️
New-GSTeamDrive ✔️ ✔️
Remove-GSTeamDrive ✔️ ✔️
Update-GSDriveFile ✔️ ✔️
Update-GSSheetValue ✔️ ✔️
Update-GSTeamDrive ✔️ ✔️
Start-GSDriveFileUpload ✔️ ✔️
Get-GSDriveFileUploadStatus ✔️ ✔️

Other Tasks

  • Update documentation
  • Build out ChangeLog to document any breaking changes
  • Update Pester Tests
  • Add in CI configuration for AppVeyor
    • Build out Travis CI tests for Linux/macOS? Skipped for now, using pwsh support in AppVeyor to test PowerShell Core compatibility
  • Clean up PSGSuite2 to PSGSuite in prep for deployment to PSGallery
  • DEPLOY PSGSuite 2.0.0!

Get-GSDriveFileList and memory usage

When querying large file drive structures the responses are grouped and held in memory by the Get-GSDriveFileList command.

This occurs because of the unnecessary use of array concatenation using the response variable in the block below.

$response = @()
[int]$i = 1
do {
    $result = $request.Execute()
    $response += $result.Files | Select-Object @{N = 'User';E = {$User}},*
    if ($result.NextPageToken) {
        $request.PageToken = $result.NextPageToken
    }
    [int]$retrieved = ($i + $result.Files.Count) - 1
    Write-Verbose "Retrieved $retrieved Files..."
    [int]$i = $i + $result.Files.Count
}
until (!$result.NextPageToken)
$response

This change removes the assignment, results will be immediately written to the output pipeline. A secondary benefit is that this version should perform better as it loses the expensive array creation / copy operation hidden behind +=.

[int]$i = 1
do {
    $result = $request.Execute()
    $result.Files | Select-Object @{N = 'User';E = {$User}},*
    if ($result.NextPageToken) {
        $request.PageToken = $result.NextPageToken
    }
    [int]$retrieved = ($i + $result.Files.Count) - 1
    Write-Verbose "Retrieved $retrieved Files..."
    [int]$i = $i + $result.Files.Count
}
until (!$result.NextPageToken)

Memory will only be consumed by this command for each page, or if the requestor performs their own assignment.

Are you happy with the change? Would you like a pull request?

New-GSUser with -CustomSchemas

Feature request: -CustomSchemas parameter for New-GSUser so you do not have to call Update-GSUser just after creating one.

[Feedback] What additional Google API's would YOU like to see added to PSGSuite?

PSGSuite was originally created for personal and work-related automation, so functions were created somewhat sporadically without 100% coverage of each API in scope. For most, the functions available should cover what's needed, but I'd like to increase the coverage as much as possible!

Please leave a comment with any Google APIs/endpoints* you would like to see added into PSGSuite! If you have a link to Google's documentation page for that API, that would be appreciated as well to remove any possible confusion.

*At the moment, this is going to be somewhat limited to APIs outside of Google Cloud Platform, but if the demand is there, I'm open to digging into GCP API's like Vision API and the like.

Looking forward!

  • Nate

Progress Checklist

  • Gmail Settings (IMAP, POP, Auto Forwarding, Vacation) [Added in v2.2.0]
  • CalendarSubscription management [Added in v2.3.0]
  • User Aliases [Added in v2.3.0]
  • Group Aliases [Added in v2.3.0]
  • Update User's Schema values [Added in v2.5.0]
  • Contact Management: Issue #53
  • SuperAdmin & Admin Role management: Issue #54
  • Updating Drive files: Issue #55
  • Updating Google Docs like local text files (Out-File/Set-Content parity): Issue #56

Waffle.io - Columns and their card count

Issue with Add-GSUserExternalId

$extId = Add-GSUserExternalId -Type Login_Id -Value jsmith2

Response:
Add-GSUserExternalId : Cannot validate argument on parameter 'Value'. The argument "jsmith2" does not belong to the set "account,custom,customer,login_id,network,organization" specified by the ValidateSet attribute
. Supply an argument that is in the set and then try the command again.

Update initial setup instructions

On the initial setup instructions, for adding the API access to the admin console, it says to enter the ServiceAccountClientID and API scopes. The client ID would not work for me, I needed to enter the actual account name with the domain at the end, ie: [email protected] for the client name.

Can't change WhoCanJoin attribute on Update-GSGroupSettings

I am attempting to change the whoCanJoin attribute via the Update-GSGroupSettings cmdlet and it does not change. I don't even get an error.

I know that I am authorized because I can change any other attribute and it works.

I get a response back from the API with no error code, but the attribute is not changed. The command I am running is:

update-GSGroupSettings -group [email protected] -WhoCanJoin "ALL_IN_DOMAIN_CAN_JOIN"

If someone wouldn't mind testing that would be awesome. I am not sure if it is a pre-requisite issue or what.

[Enhancement] Use Message Queues to handle Drive File uploads

Currently, Start-GSDriveFileUpload uploads Drive Files asynchronously, but it does so in batches. Batch count is controlled by the ThrottleLimit parameter, which defaults to 20. The problem this causes is that if there is a large file in that batch, the batch waits until all files within it have completed or failed before moving on to the next batch. If this was handled via Message Queues instead (i.e. BlockCollection), it would handle uploading much more efficiently by invoking workers to individually manage each upload in the queue, invoking the next one as soon as the current finishes.

[Feature Request] Allow Sheet uploads greater than 10 MB

I have a process that uploads a sheet with about 25 MB worth of data when formatted into a Google Sheets API compatible object (the actual data itself is about 3 MB when exported as CSV).

When trying to use Export-GSSheet on this data, I receive the following:

Export-GSSheet : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
Request payload size exceeds the limit: 10485760 bytes. [400]
Errors [
        Message[Request payload size exceeds the limit: 10485760 bytes.] Location[ - ] Reason[badRequest] Domain[global]
]
"
At line:94 char:35
+ ... t = $billingTable | Export-GSSheet -NewSheetTitle $SheetName -Verbose
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Export-GSSheet

Add Gmail Delegation Commands to PSGSuite v2+

Email Settings API is currently the only way to perform Gmail Delegation, but the API is deprecated for the newer Gmail API. Gmail API does not yet support delegation tasks though and there is no apparent .NET SDK for the Email Settings API. Expected completion of delegation setting addition to the Gmail API is Q3 of 2018.

Issue to track progress on building a workaround or integrating Gmail API for delegation if released sooner. If you need to perform delegation tasks with PSGSuite, stick to the previous releases until this issue is resolved.

[Question] Having issues with autorization after initial setup

I ran through the initial setup successfully, ran the setup command which went fine. When attempting to do Get-GSUser I get an error

Get-GSUser : Exception calling "Execute" with "0" argument(s): "Error:"unauthorized_client",Description:"Client is unauthorized to retrieve access tokens using this method.", Uri:"""

New-GSOrganizationalUnit not working

Hello, I am experiencing the following issue with New-GSOrganizationalUnit.

PS C:\scripts\automation> New-GSOrganizationalUnit

cmdlet New-GSOrganizationalUnit at command pipeline position 1
Supply values for the following parameters:
Name: test
New-GSOrganizationalUnit : Method invocation failed because [Google.Apis.Admin.Directory.directory_v1.Data.OrgUnit]
does not contain a method named 'new'.
At line:1 char:1
+ New-GSOrganizationalUnit
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-GSOrganizationalUnit

Update pipeline compatibility and fix output object types

PSGSuite already supports pipeline, but parts of it can be somewhat non-intuitive to use (i.e. piping Get-GSUser -Filter "IsAdmin -eq '$false'" | Update-GSUser -Suspended:$false would not actually unsuspend all the admins, as it would attempt to pass the entire User object and not just the PrimaryEmail)

Also, this will simultaneously remove the Select-Object calls after each object, instead using Add-Member to not break the object type.

All in all, here's what's planned:

  1. Replace Select-Object with Add-Member:
# From this...
$userObj | 
	Select-Object @{N = "User";E = {$User}},*

# To this...
$userObj | 
	Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
  1. Override the built-in ToString() method on the object:
$userObj | 
	Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru  | 
	Add-Member -MemberType ScriptMethod -Name ToString -Value {$this.PrimaryEmail} -PassThru -Force

Update-GSCalendarEvent sets default Start/End times if not passed

Working with @Rtistx on this, should be a quick fix.

Issue is that if you do not specify a Start and/or End time when updating a Calendar event with Update-GSCalendarEvent, it will set the start time as the time the command was run and the end time 30 minutes after that point due to the parameters LocalStartTime and LocalEndTime having the same default values as New-GSCalendarEvent

Code that needs updating is here:

https://github.com/scrthq/PSGSuite/blob/master/PSGSuite/Public/Calendar/Update-GSCalendarEvent.ps1#L104..L107 (needs to have the default values removed)

https://github.com/scrthq/PSGSuite/blob/master/PSGSuite/Public/Calendar/Update-GSCalendarEvent.ps1#L183 (needs to be changed to an elseif statement)

https://github.com/scrthq/PSGSuite/blob/master/PSGSuite/Public/Calendar/Update-GSCalendarEvent.ps1#L198 (needs to be changed to an elseif statement)

Update-GSUser failing to update OrgUnitPath

Update-GSUser : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
Required parameter: [resource.name.field] [400]
Errors [
        Message[Required parameter: [resource.name.field]] Location[[resource.name.field] - parameter] Reason[required] Domain[global]
]
"
At line:4 char:5
+     Update-GSUser -User $user.primaryEmail -OrgUnitPath "/Users/Servi ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Update-GSUser], MethodInvocationException
    + FullyQualifiedErrorId : GoogleApiException,Update-GSUser

Get-GSUser output

I'd like to be able to output the results of Get-GSUser to a Powershell $ variable. Currently, it returns just "Google.Apis.Admin.Directory.directory_v1.Data.User" unless I run the command without trying to add it to a $ variable

Replace parameter sets

This is to clean up the remaining Internal / External token parameter sets on some of the functions. The function bodies already contain a switch if an AccessToken is not provided, this frees up parameter sets for other reasons within the function if needed, since an AccessToken will indefinitely need to be acquired for every function to work correctly in one way or another.

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.