Skip to content

Commit

Permalink
!deploy v2.20.1 - added Update-GSGroupMember for #121
Browse files Browse the repository at this point in the history
## 2.20.1

* [Issue #121](#121)
  * Added: `Update-GSGroupMember` to allow setting a group member's Role and/or DeliverySettings
* Miscellaneous
  * Added: GitHub release automation to deploy task
  * Added: Twitter update automation on new version release to deploy task
  • Loading branch information
scrthq authored Nov 25, 2018
2 parents f3ddd3d + 7520133 commit ac56d51
Show file tree
Hide file tree
Showing 10 changed files with 392 additions and 152 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ FunctionBackups
FunctionBackups/*
BuildOutput/*
*config.csv
PSGSuite.zip
126 changes: 68 additions & 58 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,76 @@
# Changelog

* [Changelog](#changelog)
* [2.20.0](#2200)
* [2.19.0](#2190)
* [2.18.1](#2181)
* [2.18.0](#2180)
* [2.17.2](#2172)
* [2.17.1](#2171)
* [2.17.0](#2170)
* [2.16.1](#2161)
* [2.16.0](#2160)
* [2.15.4](#2154)
* [2.15.3](#2153)
* [2.15.2](#2152)
* [2.15.1](#2151)
* [2.15.0](#2150)
* [2.14.1](#2141)
* [2.14.0](#2140)
* [2.13.2](#2132)
* [2.13.1](#2131)
* [2.13.0](#2130)
* [2.12.1](#2121)
* [2.12.0](#2120)
* [2.11.0](#2110)
* [2.10.2](#2102)
* [2.10.1](#2101)
* [2.10.0](#2100)
* [2.9.0](#290)
* [2.8.1](#281)
* [2.8.0](#280)
* [2.7.2](#272)
* [2.7.1](#271)
* [2.7.0](#270)
* [2.6.3](#263)
* [2.6.2](#262)
* [2.6.1](#261)
* [2.6.0](#260)
* [2.5.4](#254)
* [2.5.3](#253)
* [2.5.2](#252)
* [2.5.1](#251)
* [2.5.0](#250)
* [2.4.0](#240)
* [2.3.0](#230)
* [2.2.1](#221)
* [2.2.0](#220)
* [2.1.5](#215)
* [2.1.3 / 2.1.4](#213--214)
* [2.1.2](#212)
* [2.1.1](#211)
* [2.1.0](#210)
* [2.0.3](#203)
* [2.0.2](#202)
* [2.0.1](#201)
* [2.0.0](#200)
* [New Functionality](#new-functionality)
* [Breaking Changes in 2.0.0](#breaking-changes-in-200)
* [Gmail Delegation Management Removed](#gmail-delegation-management-removed)
* [Functions Removed](#functions-removed)
* [Functions Aliased](#functions-aliased)
* [2.20.1](#2201)
* [2.20.0](#2200)
* [2.19.0](#2190)
* [2.18.1](#2181)
* [2.18.0](#2180)
* [2.17.2](#2172)
* [2.17.1](#2171)
* [2.17.0](#2170)
* [2.16.1](#2161)
* [2.16.0](#2160)
* [2.15.4](#2154)
* [2.15.3](#2153)
* [2.15.2](#2152)
* [2.15.1](#2151)
* [2.15.0](#2150)
* [2.14.1](#2141)
* [2.14.0](#2140)
* [2.13.2](#2132)
* [2.13.1](#2131)
* [2.13.0](#2130)
* [2.12.1](#2121)
* [2.12.0](#2120)
* [2.11.0](#2110)
* [2.10.2](#2102)
* [2.10.1](#2101)
* [2.10.0](#2100)
* [2.9.0](#290)
* [2.8.1](#281)
* [2.8.0](#280)
* [2.7.2](#272)
* [2.7.1](#271)
* [2.7.0](#270)
* [2.6.3](#263)
* [2.6.2](#262)
* [2.6.1](#261)
* [2.6.0](#260)
* [2.5.4](#254)
* [2.5.3](#253)
* [2.5.2](#252)
* [2.5.1](#251)
* [2.5.0](#250)
* [2.4.0](#240)
* [2.3.0](#230)
* [2.2.1](#221)
* [2.2.0](#220)
* [2.1.5](#215)
* [2.1.3 / 2.1.4](#213--214)
* [2.1.2](#212)
* [2.1.1](#211)
* [2.1.0](#210)
* [2.0.3](#203)
* [2.0.2](#202)
* [2.0.1](#201)
* [2.0.0](#200)
* [New Functionality](#new-functionality)
* [Breaking Changes in 2.0.0](#breaking-changes-in-200)
* [Gmail Delegation Management Removed](#gmail-delegation-management-removed)
* [Functions Removed](#functions-removed)
* [Functions Aliased](#functions-aliased)

***

## 2.20.1

* [Issue #121](https://github.com/scrthq/PSGSuite/issues/121)
* Added: `Update-GSGroupMember` to allow setting a group member's Role and/or DeliverySettings
* Miscellaneous
* Added: GitHub release automation to deploy task
* Added: Twitter update automation on new version release to deploy task

## 2.20.0

* [Issue #115](https://github.com/scrthq/PSGSuite/issues/115)
Expand Down
4 changes: 2 additions & 2 deletions PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGSuite.psm1'

# Version number of this module.
ModuleVersion = '2.20.0'
ModuleVersion = '2.20.1'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down Expand Up @@ -128,7 +128,7 @@ All other functions are either intact or have an alias included to support backw
# Prerelease = '-alpha'

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Google', 'GSuite', 'Apps', 'G', 'Suite', 'REST', 'API', 'Admin', 'PSModule', 'Directory', 'User', 'Goo.gl', 'PSEdition_Core', 'PSEdition_Desktop'
Tags = 'GSuite', 'Google', 'Apps', 'API', 'Drive', 'Gmail', 'Admin', 'Automation', 'PSEdition_Core', 'PSEdition_Desktop'

# A URL to the license for this module.
# LicenseUri = ''
Expand Down
66 changes: 0 additions & 66 deletions PSGSuite/Private/ListPrivate/Get-GSGroupMemberListPrivate.ps1

This file was deleted.

49 changes: 42 additions & 7 deletions PSGSuite/Public/Groups/Get-GSGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ function Get-GSGroupMember {
$PageSize="200"
)
Begin {
if ($PSCmdlet.ParameterSetName -eq 'Get') {
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/admin.directory.group'
ServiceType = 'Google.Apis.Admin.Directory.directory_v1.DirectoryService'
}
$service = New-GoogleService @serviceParams
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/admin.directory.group'
ServiceType = 'Google.Apis.Admin.Directory.directory_v1.DirectoryService'
}
$service = New-GoogleService @serviceParams
}
Process {
switch ($PSCmdlet.ParameterSetName) {
Expand Down Expand Up @@ -80,7 +78,44 @@ function Get-GSGroupMember {
}
}
List {
Get-GSGroupMemberListPrivate @PSBoundParameters
foreach ($Id in $Identity) {
try {
if ($Id -notlike "*@*.*") {
$Id = "$($Id)@$($Script:PSGSuite.Domain)"
}
$request = $service.Members.List($Id)
if ($PageSize) {
$request.MaxResults = $PageSize
}
if ($Roles) {
Write-Verbose "Getting all members of group '$Id' in the following role(s): $($Roles -join ',')"
$request.Roles = "$($Roles -join ',')"
}
else {
Write-Verbose "Getting all members of group '$Id'"
}
[int]$i = 1
do {
$result = $request.Execute()
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
}
$request.PageToken = $result.NextPageToken
[int]$retrieved = ($i + $result.MembersValue.Count) - 1
Write-Verbose "Retrieved $retrieved members..."
[int]$i = $i + $result.MembersValue.Count
}
until (!$result.NextPageToken)
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
}
}
Expand Down
107 changes: 107 additions & 0 deletions PSGSuite/Public/Groups/Update-GSGroupMember.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
function Update-GSGroupMember {
<#
.SYNOPSIS
Updates a group member's role and/or delivery preference
.DESCRIPTION
Updates a group member's role and/or delivery preference
.PARAMETER GroupEmail
The email or GroupID of the group to update members of
.PARAMETER Member
The member email or list of member emails that you would like to update
.PARAMETER Role
The role that you would like to update the members to
Acceptable values are:
* MEMBER
* MANAGER
* OWNER
.PARAMETER DeliverySettings
Defines mail delivery preferences of member
Acceptable values are:
* "ALL_MAIL": All messages, delivered as soon as they arrive.
* "DAILY": No more than one message a day.
* "DIGEST": Up to 25 messages bundled into a single message.
* "DISABLED": Remove subscription.
* "NONE": No messages.
.EXAMPLE
Get-GSGroupMember myGroup | Update-GSGroupMember -DeliverySettings ALL_MAIL
Updates the delivery preference for all members of group 'myGroup@domain.com' to 'ALL_MAIL'
#>
[cmdletbinding()]
Param
(
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)]
[Alias('Group')]
[String]
$GroupEmail,
[parameter(Mandatory = $true,Position = 1,ValueFromPipelineByPropertyName = $true)]
[Alias("PrimaryEmail","UserKey","Mail","User","UserEmail","Email")]
[ValidateNotNullOrEmpty()]
[String[]]
$Member,
[parameter(Mandatory = $false)]
[ValidateSet("MEMBER","MANAGER","OWNER")]
[String]
$Role,
[parameter(Mandatory = $false)]
[ValidateSet("ALL_MAIL","DAILY","DIGEST","DISABLED","NONE")]
[String]
$DeliverySettings
)
Begin {
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/admin.directory.group'
ServiceType = 'Google.Apis.Admin.Directory.directory_v1.DirectoryService'
}
$service = New-GoogleService @serviceParams
}
Process {
try {
if ($GroupEmail -notlike "*@*.*") {
$GroupEmail = "$($GroupEmail)@$($Script:PSGSuite.Domain)"
}
#$groupObj = Get-GSGroup -Group $Identity -Verbose:$false
try {
foreach ($U in $Member) {
if ($U -notlike "*@*.*") {
$U = "$($U)@$($Script:PSGSuite.Domain)"
}
Write-Verbose "Updating member '$U' of group '$GroupEmail'"
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Member'
if ($PSBoundParameters.Keys -contains 'DeliverySettings') {
$body.DeliverySettings = $PSBoundParameters['DeliverySettings']
}
if ($PSBoundParameters.Keys -contains 'Role') {
$body.Role = $PSBoundParameters['Role']
}
$request = $service.Members.Patch($body,$GroupEmail,$U)
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'Group' -Value $GroupEmail -PassThru
}
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
Loading

0 comments on commit ac56d51

Please sign in to comment.