Skip to content

Commit

Permalink
!deploy v2.35.0
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
scrthq authored Dec 29, 2019
2 parents de45646 + fb05118 commit 82bee3b
Show file tree
Hide file tree
Showing 26 changed files with 563 additions and 174 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* [PSGSuite - ChangeLog](#psgsuite---changelog)
* [2.35.0 - 2019-12-29](#2350---2019-12-29)
* [2.34.0 - 2019-11-02](#2340---2019-11-02)
* [2.33.2 - 2019-10-06](#2332---2019-10-06)
* [2.33.1 - 2019-10-06](#2331---2019-10-06)
Expand Down Expand Up @@ -104,6 +105,21 @@

# PSGSuite - ChangeLog

## 2.35.0 - 2019-12-29

* [Issue #216](https://github.com/scrthq/PSGSuite/issues/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](https://github.com/scrthq/PSGSuite/issues/221)
* Added: `Invoke-GSUserOffboarding` function to wrap common offboarding tasks for ease of access management automation.
* [Issue #248](https://github.com/scrthq/PSGSuite/issues/248)
* Fixed `Get-GSSheetInfo` so it no longer defaults `-IncludeGridData` to `$true` if not specified in `$PSBoundParameters`.
* [Issue #249](https://github.com/scrthq/PSGSuite/issues/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](https://github.com/scrthq/PSGSuite/issues/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.34.0 - 2019-11-02

* [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)!_
Expand Down
2 changes: 1 addition & 1 deletion 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.34.0'
ModuleVersion = '2.35.0'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
6 changes: 3 additions & 3 deletions PSGSuite/Private/Import-SpecificConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function Import-SpecificConfiguration {
}
else {
if (!$Scope -or $Scope -eq "Machine") {
$MachinePath = Get-StoragePath @Parameters -Scope Machine
$MachinePath = Get-ConfigurationPath @Parameters -Scope Machine
$MachinePath = Join-Path $MachinePath Configuration.psd1
$Machine = if (Test-Path $MachinePath) {
Import-Metadata $MachinePath -ErrorAction Ignore -Ordered:$Ordered
Expand All @@ -129,7 +129,7 @@ function Import-SpecificConfiguration {
}

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

if (!$Scope -or $Scope -eq "User") {
$LocalUserPath = Get-StoragePath @Parameters -Scope User
$LocalUserPath = Get-ConfigurationPath @Parameters -Scope User
$LocalUserPath = Join-Path $LocalUserPath Configuration.psd1
$LocalUser = if (Test-Path $LocalUserPath) {
Import-Metadata $LocalUserPath -ErrorAction Ignore -Ordered:$Ordered
Expand Down
10 changes: 8 additions & 2 deletions PSGSuite/Private/Resolve-Email.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ function Resolve-Email {
Param (
[parameter(Mandatory,Position = 0,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Ref[]]
$Email
$Email,
[parameter()]
[Switch]
$IsGroup
)
Process {
foreach ($e in $Email) {
if ( -not ($e.value -as [decimal])) {
if (-not $IsGroup -and -not ($e.value -as [decimal])) {
if ($e.value -ceq 'me') {
$e.value = $Script:PSGSuite.AdminEmail
}
elseif ($e.value -notlike "*@*.*") {
$e.value = "$($e.value)@$($Script:PSGSuite.Domain)"
}
}
elseif ($IsGroup -and $e.value -cnotmatch '^([\w.%+-]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,}|\d{2}[a-z\d]{13})$') {
$e.value = "$($e.value)@$($Script:PSGSuite.Domain)"
}
}
}
}
2 changes: 1 addition & 1 deletion PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function Set-PSGSuiteConfig {
if ($_p12Key) {
$configHash["$ConfigName"]['P12Key'] = $_p12Key
}
$configHash["$ConfigName"]['ConfigPath'] = (Join-Path $(Get-Module PSGSuite | Get-StoragePath -Scope $Script:ConfigScope) "Configuration.psd1")
$configHash["$ConfigName"]['ConfigPath'] = (Join-Path $(Get-Module PSGSuite | Get-ConfigurationPath -Scope $Script:ConfigScope) "Configuration.psd1")
$configHash | Export-Configuration -CompanyName 'SCRT HQ' -Name 'PSGSuite' -Scope $script:ConfigScope
if (!$NoImport) {
Get-PSGSuiteConfig -ConfigName $ConfigName -Verbose:$false
Expand Down
8 changes: 2 additions & 6 deletions PSGSuite/Public/Groups/Add-GSGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,11 @@ function Add-GSGroupMember {
}
Process {
try {
if ($Identity -notlike "*@*.*") {
$Identity = "$($Identity)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$Identity) -IsGroup
$groupObj = Get-GSGroup -Group $Identity -Verbose:$false
foreach ($U in $Member) {
try {
if ($U -notlike "*@*.*") {
$U = "$($U)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$U)
Write-Verbose "Adding '$U' as a $Role of group '$Identity'"
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Member'
$body.Email = $U
Expand Down
11 changes: 3 additions & 8 deletions PSGSuite/Public/Groups/Add-GSPrincipalGroupMembership.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,16 @@ function Add-GSPrincipalGroupMembership {
}
Process {
try {
if ($Identity -notlike "*@*.*") {
$Identity = "$($Identity)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$Identity)
try {
foreach ($U in $MemberOf) {
$groupObj = Get-GSGroup -Group $U -Verbose:$false
if ($U -notlike "*@*.*") {
$U = "$($U)@$($Script:PSGSuite.Domain)"
}
Write-Verbose "Adding '$Identity' as a $Role of group '$U'"
Write-Verbose "Adding '$Identity' as a $Role of group '$($groupObj.Email)'"
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Member'
$body.Email = $Identity
$body.Role = $Role
$request = $service.Members.Insert($body,$groupObj.Id)
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'Group' -Value $U -PassThru
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'Group' -Value $groupObj.Email -PassThru
}
}
catch {
Expand Down
12 changes: 6 additions & 6 deletions PSGSuite/Public/Groups/Get-GSGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
.DESCRIPTION
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)
.PARAMETER Group
The list of groups you would like to retrieve info for. If excluded, returns the group list instead
.PARAMETER Identity
The group or list of groups you would like to retrieve info for. If excluded, returns the group list instead
.PARAMETER Filter
Query string search. Complete documentation is at https://developers.google.com/admin-sdk/directory/v1/guides/search-groups
Expand Down Expand Up @@ -54,10 +54,10 @@
Param
(
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true,ParameterSetName = "Get")]
[Alias("Email")]
[Alias("Email","Group","GroupEmail")]
[ValidateNotNullOrEmpty()]
[String[]]
$Group,
$Identity,
[parameter(Mandatory = $false,ParameterSetName = "ListFilter")]
[Alias('Query')]
[string]
Expand Down Expand Up @@ -94,9 +94,9 @@
Process {
switch -Regex ($PSCmdlet.ParameterSetName) {
Get {
foreach ($G in $Group) {
foreach ($G in $Identity) {
try {
Resolve-Email ([ref]$G)
Resolve-Email ([ref]$G) -IsGroup
Write-Verbose "Getting group '$G'"
$request = $service.Groups.Get($G)
if ($Fields) {
Expand Down
15 changes: 6 additions & 9 deletions PSGSuite/Public/Groups/Get-GSGroupAlias.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function Get-GSGroupAlias {
.DESCRIPTION
Gets the specified G SUite Group's aliases
.PARAMETER Group
.PARAMETER Identity
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.
.EXAMPLE
Get-GSGroupAlias -Group hr
Get-GSGroupAlias -Identity hr
Gets the list of aliases for the group [email protected]
#>
Expand All @@ -19,10 +19,9 @@ function Get-GSGroupAlias {
Param
(
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)]
[Alias("Email")]
[ValidateNotNullOrEmpty()]
[Alias('GroupEmail','Group','Email')]
[String[]]
$Group
$Identity
)
Begin {
$serviceParams = @{
Expand All @@ -32,11 +31,9 @@ function Get-GSGroupAlias {
$service = New-GoogleService @serviceParams
}
Process {
foreach ($G in $Group) {
foreach ($G in $Identity) {
try {
if ($G -notlike "*@*.*") {
$G = "$($G)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$G) -IsGroup
Write-Verbose "Getting Alias list for Group '$G'"
$request = $service.Groups.Aliases.List($G)
$request.Execute() | Select-Object -ExpandProperty AliasesValue
Expand Down
14 changes: 4 additions & 10 deletions PSGSuite/Public/Groups/Get-GSGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Get-GSGroupMember {
Gets the group member list of a target group. Designed for parity with Get-ADGroupMember
.PARAMETER Identity
The email or GroupID of the target group
The email or unique ID of the target group
.PARAMETER Member
If specified, returns only the information for this member of the target group
Expand Down Expand Up @@ -63,13 +63,9 @@ function Get-GSGroupMember {
Get {
foreach ($I in $Identity) {
try {
if ($I -notlike "*@*.*") {
$I = "$($I)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$I) -IsGroup
foreach ($G in $Member) {
if ($G -notlike "*@*.*") {
$G = "$($G)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$G)
Write-Verbose "Getting member '$G' of group '$I'"
$request = $service.Members.Get($I,$G)
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'Group' -Value $I -PassThru
Expand All @@ -88,9 +84,7 @@ function Get-GSGroupMember {
List {
foreach ($Id in $Identity) {
try {
if ($Id -notlike "*@*.*") {
$Id = "$($Id)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$Id) -IsGroup
$request = $service.Members.List($Id)
if ($Limit -gt 0 -and $PageSize -gt $Limit) {
Write-Verbose ("Reducing PageSize from {0} to {1} to meet limit with first page" -f $PageSize,$Limit)
Expand Down
8 changes: 5 additions & 3 deletions PSGSuite/Public/Groups/Get-GSGroupSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Get-GSGroupSettings {
Gets a group's settings
.PARAMETER Identity
The email of the group
The email or unique ID of the group.
If only the email name-part is passed, the full email will be contstructed using the Domain from the active config
Expand Down Expand Up @@ -35,8 +35,10 @@ function Get-GSGroupSettings {
Process {
try {
foreach ($G in $Identity) {
if ($G -notlike "*@*.*") {
$G = "$($G)@$($Script:PSGSuite.Domain)"
Resolve-Email ([ref]$G) -IsGroup
if ($G -notmatch '^[\w.%+-]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,}$') {
Write-Verbose "Getting Group Email for ID '$G' as the Group Settings API only accepts Group Email addresses."
$G = Get-GSGroup -Identity $G -Verbose:$false | Select-Object -ExpandProperty Email
}
Write-Verbose "Getting settings for group '$G'"
$request = $service.Groups.Get($G)
Expand Down
9 changes: 2 additions & 7 deletions PSGSuite/Public/Groups/New-GSGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ function New-GSGroup {
}
Process {
try {
if ($Email -notlike "*@*.*") {
$Email = "$($Email)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$Email)
Write-Verbose "Creating group '$Email'"
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Group'
foreach ($prop in $PSBoundParameters.Keys | Where-Object {$body.PSObject.Properties.Name -contains $_}) {
switch ($prop) {
Email {
if ($PSBoundParameters[$prop] -notlike "*@*.*") {
$PSBoundParameters[$prop] = "$($PSBoundParameters[$prop])@$($Script:PSGSuite.Domain)"
}
$body.$prop = $PSBoundParameters[$prop]
$body.$prop = $Email
}
Default {
$body.$prop = $PSBoundParameters[$prop]
Expand Down
24 changes: 9 additions & 15 deletions PSGSuite/Public/Groups/New-GSGroupAlias.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ function New-GSGroupAlias {
.DESCRIPTION
Creates a new alias for a G Suite group
.PARAMETER Group
.PARAMETER Identity
The group to create the alias for
.PARAMETER Alias
The alias or list of aliases to create for the group
.EXAMPLE
New-GSGroupAlias -Group [email protected] -Alias '[email protected]','[email protected]'
New-GSGroupAlias -Identity [email protected] -Alias '[email protected]','[email protected]'
Creates 2 new aliases for group Human Resources as '[email protected]' and '[email protected]'
#>
[OutputType('Google.Apis.Admin.Directory.directory_v1.Data.Alias')]
[cmdletbinding()]
Param
(
Param (
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)]
[Alias("Email")]
[ValidateNotNullOrEmpty()]
[Alias('GroupEmail','Group','Email')]
[String]
$Group,
$Identity,
[parameter(Mandatory = $true,Position = 1)]
[String[]]
$Alias
Expand All @@ -38,18 +36,14 @@ function New-GSGroupAlias {
$service = New-GoogleService @serviceParams
}
Process {
Resolve-Email ([ref]$Identity) -IsGroup
foreach ($A in $Alias) {
try {
if ($Group -notlike "*@*.*") {
$Group = "$($Group)@$($Script:PSGSuite.Domain)"
}
if ($A -notlike "*@*.*") {
$A = "$($A)@$($Script:PSGSuite.Domain)"
}
Write-Verbose "Creating alias '$A' for Group '$Group'"
Resolve-Email ([ref]$A)
Write-Verbose "Creating alias '$A' for Group '$Identity'"
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.Alias'
$body.AliasValue = $A
$request = $service.Groups.Aliases.Insert($body,$Group)
$request = $service.Groups.Aliases.Insert($body,$Identity)
$request.Execute()
}
catch {
Expand Down
15 changes: 6 additions & 9 deletions PSGSuite/Public/Groups/Remove-GSGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
<#
.SYNOPSIS
Removes a group
.DESCRIPTION
Removes a group
.PARAMETER Identity
The email or unique Id of the group to removed
.EXAMPLE
Remove-GSGroup 'test_group' -Confirm:$false
Removes the group '[email protected]' without asking for confirmation
#>
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact = "High")]
Param
(
Param (
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)]
[Alias('GroupEmail','Group','Email')]
[String[]]
Expand All @@ -32,9 +31,7 @@
Process {
try {
foreach ($G in $Identity) {
if ($G -notlike "*@*.*") {
$G = "$($G)@$($Script:PSGSuite.Domain)"
}
Resolve-Email ([ref]$G) -IsGroup
if ($PSCmdlet.ShouldProcess("Removing group '$G'")) {
Write-Verbose "Removing group '$G'"
$request = $service.Groups.Delete($G)
Expand All @@ -52,4 +49,4 @@
}
}
}
}
}
Loading

0 comments on commit 82bee3b

Please sign in to comment.