Skip to content

Commit 82bee3b

Browse files
authored
!deploy v2.35.0
## 2.35.0 - 2019-12-29 * [Issue #216](#216) - _Thank you, [@WJurecki](https://github.com/WJurecki)!_ * Added `Add-GSSheetValues` to use the native `Append()` method instead of `BatchUpdate()` to prevent needing to calculate the last row like you do with `Export-GSSheet`. Since the input for this method has additional options and the output differs from what `Export-GSSheet` outputs, this has been moved to a unique function to prevent introducing breaking changes to `Export-GSSheet`. * [Issue #221](#221) * Added: `Invoke-GSUserOffboarding` function to wrap common offboarding tasks for ease of access management automation. * [Issue #248](#248) * Fixed `Get-GSSheetInfo` so it no longer defaults `-IncludeGridData` to `$true` if not specified in `$PSBoundParameters`. * [Issue #249](#249) * Updated private function `Resolve-Email` with new `IsGroup` switch, then cleaned up all `*-GSGroup*` functions to use it so that Group ID's are respected based on RegEx match. * [Issue #252](#252) * Added: `Archived` parameter to `Update-GSUser` to enable setting of Archived User licenses. * Miscellaneous * Swapped instances of `Get-StoragePath` for `Get-ConfigurationPath` in `Import-SpecificConfiguration` and `Set-PSGSuiteConfig` to avoid alias related issues with PowerShell 4.0
2 parents de45646 + fb05118 commit 82bee3b

26 files changed

+563
-174
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* [PSGSuite - ChangeLog](#psgsuite---changelog)
2+
* [2.35.0 - 2019-12-29](#2350---2019-12-29)
23
* [2.34.0 - 2019-11-02](#2340---2019-11-02)
34
* [2.33.2 - 2019-10-06](#2332---2019-10-06)
45
* [2.33.1 - 2019-10-06](#2331---2019-10-06)
@@ -104,6 +105,21 @@
104105

105106
# PSGSuite - ChangeLog
106107

108+
## 2.35.0 - 2019-12-29
109+
110+
* [Issue #216](https://github.com/scrthq/PSGSuite/issues/216) - _Thank you, [@WJurecki](https://github.com/WJurecki)!_
111+
* Added `Add-GSSheetValues` to use the native `Append()` method instead of `BatchUpdate()` to prevent needing to calculate the last row like you do with `Export-GSSheet`. Since the input for this method has additional options and the output differs from what `Export-GSSheet` outputs, this has been moved to a unique function to prevent introducing breaking changes to `Export-GSSheet`.
112+
* [Issue #221](https://github.com/scrthq/PSGSuite/issues/221)
113+
* Added: `Invoke-GSUserOffboarding` function to wrap common offboarding tasks for ease of access management automation.
114+
* [Issue #248](https://github.com/scrthq/PSGSuite/issues/248)
115+
* Fixed `Get-GSSheetInfo` so it no longer defaults `-IncludeGridData` to `$true` if not specified in `$PSBoundParameters`.
116+
* [Issue #249](https://github.com/scrthq/PSGSuite/issues/249)
117+
* Updated private function `Resolve-Email` with new `IsGroup` switch, then cleaned up all `*-GSGroup*` functions to use it so that Group ID's are respected based on RegEx match.
118+
* [Issue #252](https://github.com/scrthq/PSGSuite/issues/252)
119+
* Added: `Archived` parameter to `Update-GSUser` to enable setting of Archived User licenses.
120+
* Miscellaneous
121+
* Swapped instances of `Get-StoragePath` for `Get-ConfigurationPath` in `Import-SpecificConfiguration` and `Set-PSGSuiteConfig` to avoid alias related issues with PowerShell 4.0
122+
107123
## 2.34.0 - 2019-11-02
108124

109125
* [Issue #245](https://github.com/scrthq/PSGSuite/issues/245) + [PR #246](https://github.com/scrthq/PSGSuite/pull/246) - _Thank you, [@devblackops](https://github.com/devblackops)!_

PSGSuite/PSGSuite.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSGSuite.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.34.0'
15+
ModuleVersion = '2.35.0'
1616

1717
# ID used to uniquely identify this module
1818
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'

PSGSuite/Private/Import-SpecificConfiguration.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function Import-SpecificConfiguration {
117117
}
118118
else {
119119
if (!$Scope -or $Scope -eq "Machine") {
120-
$MachinePath = Get-StoragePath @Parameters -Scope Machine
120+
$MachinePath = Get-ConfigurationPath @Parameters -Scope Machine
121121
$MachinePath = Join-Path $MachinePath Configuration.psd1
122122
$Machine = if (Test-Path $MachinePath) {
123123
Import-Metadata $MachinePath -ErrorAction Ignore -Ordered:$Ordered
@@ -129,7 +129,7 @@ function Import-SpecificConfiguration {
129129
}
130130

131131
if (!$Scope -or $Scope -eq "Enterprise") {
132-
$EnterprisePath = Get-StoragePath @Parameters -Scope Enterprise
132+
$EnterprisePath = Get-ConfigurationPath @Parameters -Scope Enterprise
133133
$EnterprisePath = Join-Path $EnterprisePath Configuration.psd1
134134
$Enterprise = if (Test-Path $EnterprisePath) {
135135
Import-Metadata $EnterprisePath -ErrorAction Ignore -Ordered:$Ordered
@@ -141,7 +141,7 @@ function Import-SpecificConfiguration {
141141
}
142142

143143
if (!$Scope -or $Scope -eq "User") {
144-
$LocalUserPath = Get-StoragePath @Parameters -Scope User
144+
$LocalUserPath = Get-ConfigurationPath @Parameters -Scope User
145145
$LocalUserPath = Join-Path $LocalUserPath Configuration.psd1
146146
$LocalUser = if (Test-Path $LocalUserPath) {
147147
Import-Metadata $LocalUserPath -ErrorAction Ignore -Ordered:$Ordered

PSGSuite/Private/Resolve-Email.ps1

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ function Resolve-Email {
33
Param (
44
[parameter(Mandatory,Position = 0,ValueFromPipeline,ValueFromPipelineByPropertyName)]
55
[Ref[]]
6-
$Email
6+
$Email,
7+
[parameter()]
8+
[Switch]
9+
$IsGroup
710
)
811
Process {
912
foreach ($e in $Email) {
10-
if ( -not ($e.value -as [decimal])) {
13+
if (-not $IsGroup -and -not ($e.value -as [decimal])) {
1114
if ($e.value -ceq 'me') {
1215
$e.value = $Script:PSGSuite.AdminEmail
1316
}
1417
elseif ($e.value -notlike "*@*.*") {
1518
$e.value = "$($e.value)@$($Script:PSGSuite.Domain)"
1619
}
1720
}
21+
elseif ($IsGroup -and $e.value -cnotmatch '^([\w.%+-]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,}|\d{2}[a-z\d]{13})$') {
22+
$e.value = "$($e.value)@$($Script:PSGSuite.Domain)"
23+
}
1824
}
1925
}
2026
}

PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function Set-PSGSuiteConfig {
233233
if ($_p12Key) {
234234
$configHash["$ConfigName"]['P12Key'] = $_p12Key
235235
}
236-
$configHash["$ConfigName"]['ConfigPath'] = (Join-Path $(Get-Module PSGSuite | Get-StoragePath -Scope $Script:ConfigScope) "Configuration.psd1")
236+
$configHash["$ConfigName"]['ConfigPath'] = (Join-Path $(Get-Module PSGSuite | Get-ConfigurationPath -Scope $Script:ConfigScope) "Configuration.psd1")
237237
$configHash | Export-Configuration -CompanyName 'SCRT HQ' -Name 'PSGSuite' -Scope $script:ConfigScope
238238
if (!$NoImport) {
239239
Get-PSGSuiteConfig -ConfigName $ConfigName -Verbose:$false

PSGSuite/Public/Groups/Add-GSGroupMember.ps1

+2-6
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,11 @@ function Add-GSGroupMember {
4949
}
5050
Process {
5151
try {
52-
if ($Identity -notlike "*@*.*") {
53-
$Identity = "$($Identity)@$($Script:PSGSuite.Domain)"
54-
}
52+
Resolve-Email ([ref]$Identity) -IsGroup
5553
$groupObj = Get-GSGroup -Group $Identity -Verbose:$false
5654
foreach ($U in $Member) {
5755
try {
58-
if ($U -notlike "*@*.*") {
59-
$U = "$($U)@$($Script:PSGSuite.Domain)"
60-
}
56+
Resolve-Email ([ref]$U)
6157
Write-Verbose "Adding '$U' as a $Role of group '$Identity'"
6258
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Member'
6359
$body.Email = $U

PSGSuite/Public/Groups/Add-GSPrincipalGroupMembership.ps1

+3-8
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,16 @@ function Add-GSPrincipalGroupMembership {
4949
}
5050
Process {
5151
try {
52-
if ($Identity -notlike "*@*.*") {
53-
$Identity = "$($Identity)@$($Script:PSGSuite.Domain)"
54-
}
52+
Resolve-Email ([ref]$Identity)
5553
try {
5654
foreach ($U in $MemberOf) {
5755
$groupObj = Get-GSGroup -Group $U -Verbose:$false
58-
if ($U -notlike "*@*.*") {
59-
$U = "$($U)@$($Script:PSGSuite.Domain)"
60-
}
61-
Write-Verbose "Adding '$Identity' as a $Role of group '$U'"
56+
Write-Verbose "Adding '$Identity' as a $Role of group '$($groupObj.Email)'"
6257
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Member'
6358
$body.Email = $Identity
6459
$body.Role = $Role
6560
$request = $service.Members.Insert($body,$groupObj.Id)
66-
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'Group' -Value $U -PassThru
61+
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'Group' -Value $groupObj.Email -PassThru
6762
}
6863
}
6964
catch {

PSGSuite/Public/Groups/Get-GSGroup.ps1

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
.DESCRIPTION
77
Gets the specified group's information. Returns the full group list if -Group is excluded. Designed for parity with Get-ADGroup (although Google's API is unable to 'Filter' for groups)
88
9-
.PARAMETER Group
10-
The list of groups you would like to retrieve info for. If excluded, returns the group list instead
9+
.PARAMETER Identity
10+
The group or list of groups you would like to retrieve info for. If excluded, returns the group list instead
1111
1212
.PARAMETER Filter
1313
Query string search. Complete documentation is at https://developers.google.com/admin-sdk/directory/v1/guides/search-groups
@@ -54,10 +54,10 @@
5454
Param
5555
(
5656
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true,ParameterSetName = "Get")]
57-
[Alias("Email")]
57+
[Alias("Email","Group","GroupEmail")]
5858
[ValidateNotNullOrEmpty()]
5959
[String[]]
60-
$Group,
60+
$Identity,
6161
[parameter(Mandatory = $false,ParameterSetName = "ListFilter")]
6262
[Alias('Query')]
6363
[string]
@@ -94,9 +94,9 @@
9494
Process {
9595
switch -Regex ($PSCmdlet.ParameterSetName) {
9696
Get {
97-
foreach ($G in $Group) {
97+
foreach ($G in $Identity) {
9898
try {
99-
Resolve-Email ([ref]$G)
99+
Resolve-Email ([ref]$G) -IsGroup
100100
Write-Verbose "Getting group '$G'"
101101
$request = $service.Groups.Get($G)
102102
if ($Fields) {

PSGSuite/Public/Groups/Get-GSGroupAlias.ps1

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ function Get-GSGroupAlias {
66
.DESCRIPTION
77
Gets the specified G SUite Group's aliases
88
9-
.PARAMETER Group
9+
.PARAMETER Identity
1010
The primary email or ID of the group who you are trying to get aliases for. You can exclude the '@domain.com' to insert the Domain in the config or use the special 'me' to indicate the AdminEmail in the config.
1111
1212
.EXAMPLE
13-
Get-GSGroupAlias -Group hr
13+
Get-GSGroupAlias -Identity hr
1414
1515
Gets the list of aliases for the group [email protected]
1616
#>
@@ -19,10 +19,9 @@ function Get-GSGroupAlias {
1919
Param
2020
(
2121
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)]
22-
[Alias("Email")]
23-
[ValidateNotNullOrEmpty()]
22+
[Alias('GroupEmail','Group','Email')]
2423
[String[]]
25-
$Group
24+
$Identity
2625
)
2726
Begin {
2827
$serviceParams = @{
@@ -32,11 +31,9 @@ function Get-GSGroupAlias {
3231
$service = New-GoogleService @serviceParams
3332
}
3433
Process {
35-
foreach ($G in $Group) {
34+
foreach ($G in $Identity) {
3635
try {
37-
if ($G -notlike "*@*.*") {
38-
$G = "$($G)@$($Script:PSGSuite.Domain)"
39-
}
36+
Resolve-Email ([ref]$G) -IsGroup
4037
Write-Verbose "Getting Alias list for Group '$G'"
4138
$request = $service.Groups.Aliases.List($G)
4239
$request.Execute() | Select-Object -ExpandProperty AliasesValue

PSGSuite/Public/Groups/Get-GSGroupMember.ps1

+4-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Get-GSGroupMember {
77
Gets the group member list of a target group. Designed for parity with Get-ADGroupMember
88
99
.PARAMETER Identity
10-
The email or GroupID of the target group
10+
The email or unique ID of the target group
1111
1212
.PARAMETER Member
1313
If specified, returns only the information for this member of the target group
@@ -63,13 +63,9 @@ function Get-GSGroupMember {
6363
Get {
6464
foreach ($I in $Identity) {
6565
try {
66-
if ($I -notlike "*@*.*") {
67-
$I = "$($I)@$($Script:PSGSuite.Domain)"
68-
}
66+
Resolve-Email ([ref]$I) -IsGroup
6967
foreach ($G in $Member) {
70-
if ($G -notlike "*@*.*") {
71-
$G = "$($G)@$($Script:PSGSuite.Domain)"
72-
}
68+
Resolve-Email ([ref]$G)
7369
Write-Verbose "Getting member '$G' of group '$I'"
7470
$request = $service.Members.Get($I,$G)
7571
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'Group' -Value $I -PassThru
@@ -88,9 +84,7 @@ function Get-GSGroupMember {
8884
List {
8985
foreach ($Id in $Identity) {
9086
try {
91-
if ($Id -notlike "*@*.*") {
92-
$Id = "$($Id)@$($Script:PSGSuite.Domain)"
93-
}
87+
Resolve-Email ([ref]$Id) -IsGroup
9488
$request = $service.Members.List($Id)
9589
if ($Limit -gt 0 -and $PageSize -gt $Limit) {
9690
Write-Verbose ("Reducing PageSize from {0} to {1} to meet limit with first page" -f $PageSize,$Limit)

PSGSuite/Public/Groups/Get-GSGroupSettings.ps1

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Get-GSGroupSettings {
77
Gets a group's settings
88
99
.PARAMETER Identity
10-
The email of the group
10+
The email or unique ID of the group.
1111
1212
If only the email name-part is passed, the full email will be contstructed using the Domain from the active config
1313
@@ -35,8 +35,10 @@ function Get-GSGroupSettings {
3535
Process {
3636
try {
3737
foreach ($G in $Identity) {
38-
if ($G -notlike "*@*.*") {
39-
$G = "$($G)@$($Script:PSGSuite.Domain)"
38+
Resolve-Email ([ref]$G) -IsGroup
39+
if ($G -notmatch '^[\w.%+-]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,}$') {
40+
Write-Verbose "Getting Group Email for ID '$G' as the Group Settings API only accepts Group Email addresses."
41+
$G = Get-GSGroup -Identity $G -Verbose:$false | Select-Object -ExpandProperty Email
4042
}
4143
Write-Verbose "Getting settings for group '$G'"
4244
$request = $service.Groups.Get($G)

PSGSuite/Public/Groups/New-GSGroup.ps1

+2-7
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,13 @@ function New-GSGroup {
4343
}
4444
Process {
4545
try {
46-
if ($Email -notlike "*@*.*") {
47-
$Email = "$($Email)@$($Script:PSGSuite.Domain)"
48-
}
46+
Resolve-Email ([ref]$Email)
4947
Write-Verbose "Creating group '$Email'"
5048
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Group'
5149
foreach ($prop in $PSBoundParameters.Keys | Where-Object {$body.PSObject.Properties.Name -contains $_}) {
5250
switch ($prop) {
5351
Email {
54-
if ($PSBoundParameters[$prop] -notlike "*@*.*") {
55-
$PSBoundParameters[$prop] = "$($PSBoundParameters[$prop])@$($Script:PSGSuite.Domain)"
56-
}
57-
$body.$prop = $PSBoundParameters[$prop]
52+
$body.$prop = $Email
5853
}
5954
Default {
6055
$body.$prop = $PSBoundParameters[$prop]

PSGSuite/Public/Groups/New-GSGroupAlias.ps1

+9-15
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,24 @@ function New-GSGroupAlias {
66
.DESCRIPTION
77
Creates a new alias for a G Suite group
88
9-
.PARAMETER Group
9+
.PARAMETER Identity
1010
The group to create the alias for
1111
1212
.PARAMETER Alias
1313
The alias or list of aliases to create for the group
1414
1515
.EXAMPLE
16-
New-GSGroupAlias -Group [email protected] -Alias '[email protected]','[email protected]'
16+
New-GSGroupAlias -Identity [email protected] -Alias '[email protected]','[email protected]'
1717
1818
Creates 2 new aliases for group Human Resources as '[email protected]' and '[email protected]'
1919
#>
2020
[OutputType('Google.Apis.Admin.Directory.directory_v1.Data.Alias')]
2121
[cmdletbinding()]
22-
Param
23-
(
22+
Param (
2423
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)]
25-
[Alias("Email")]
26-
[ValidateNotNullOrEmpty()]
24+
[Alias('GroupEmail','Group','Email')]
2725
[String]
28-
$Group,
26+
$Identity,
2927
[parameter(Mandatory = $true,Position = 1)]
3028
[String[]]
3129
$Alias
@@ -38,18 +36,14 @@ function New-GSGroupAlias {
3836
$service = New-GoogleService @serviceParams
3937
}
4038
Process {
39+
Resolve-Email ([ref]$Identity) -IsGroup
4140
foreach ($A in $Alias) {
4241
try {
43-
if ($Group -notlike "*@*.*") {
44-
$Group = "$($Group)@$($Script:PSGSuite.Domain)"
45-
}
46-
if ($A -notlike "*@*.*") {
47-
$A = "$($A)@$($Script:PSGSuite.Domain)"
48-
}
49-
Write-Verbose "Creating alias '$A' for Group '$Group'"
42+
Resolve-Email ([ref]$A)
43+
Write-Verbose "Creating alias '$A' for Group '$Identity'"
5044
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Alias'
5145
$body.AliasValue = $A
52-
$request = $service.Groups.Aliases.Insert($body,$Group)
46+
$request = $service.Groups.Aliases.Insert($body,$Identity)
5347
$request.Execute()
5448
}
5549
catch {

PSGSuite/Public/Groups/Remove-GSGroup.ps1

+6-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22
<#
33
.SYNOPSIS
44
Removes a group
5-
5+
66
.DESCRIPTION
77
Removes a group
8-
8+
99
.PARAMETER Identity
1010
The email or unique Id of the group to removed
11-
11+
1212
.EXAMPLE
1313
Remove-GSGroup 'test_group' -Confirm:$false
1414
1515
Removes the group '[email protected]' without asking for confirmation
1616
#>
1717
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact = "High")]
18-
Param
19-
(
18+
Param (
2019
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)]
2120
[Alias('GroupEmail','Group','Email')]
2221
[String[]]
@@ -32,9 +31,7 @@
3231
Process {
3332
try {
3433
foreach ($G in $Identity) {
35-
if ($G -notlike "*@*.*") {
36-
$G = "$($G)@$($Script:PSGSuite.Domain)"
37-
}
34+
Resolve-Email ([ref]$G) -IsGroup
3835
if ($PSCmdlet.ShouldProcess("Removing group '$G'")) {
3936
Write-Verbose "Removing group '$G'"
4037
$request = $service.Groups.Delete($G)
@@ -52,4 +49,4 @@
5249
}
5350
}
5451
}
55-
}
52+
}

0 commit comments

Comments
 (0)