Skip to content

Commit

Permalink
v2.26.2 adding features and squashing bugs
Browse files Browse the repository at this point in the history
## 2.26.2

* [Issue #177](#177)
  * Added: `Fields` parameter to `Get-GSDriveFileList`
* [Issue #178](#178)
  * Fixed: `Start-GSDriveFileUpload` failing on PowerShell 4.0
* [Issue #179](#179)
  * Added: `Ims` parameter to both `New-GSUser` and `Update-GSUser`
  * Added: `Add-GSUserIm` function to create correct type for new `Ims` parameter.
* Miscellaneous
  * Added: `Clear-PSGSuiteServiceCache` to clear the cache and dispose of any remaining open web clients.
  * Improved overall service caching.
  * Added: Support for `Cloud-Identity` licenses for `Get-GSUserLicense`
  * Added: `OutputType` for all applicable Helper functions (i.e. `Add-GSUserIm`)
  • Loading branch information
scrthq authored Apr 25, 2019
2 parents 1416c90 + f04e507 commit 453728f
Show file tree
Hide file tree
Showing 26 changed files with 525 additions and 201 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

* [Changelog](#changelog)
* [2.26.2](#2262)
* [2.26.1](#2261)
* [2.26.0](#2260)
* [2.25.3](#2253)
Expand Down Expand Up @@ -83,6 +84,21 @@

***

## 2.26.2

* [Issue #177](https://github.com/scrthq/PSGSuite/issues/177)
* Added: `Fields` parameter to `Get-GSDriveFileList`
* [Issue #178](https://github.com/scrthq/PSGSuite/issues/178)
* Fixed: `Start-GSDriveFileUpload` failing on PowerShell 4.0
* [Issue #179](https://github.com/scrthq/PSGSuite/issues/179)
* Added: `Ims` parameter to both `New-GSUser` and `Update-GSUser`
* Added: `Add-GSUserIm` function to create correct type for new `Ims` parameter.
* Miscellaneous
* Added: `Clear-PSGSuiteServiceCache` to clear the cache and dispose of any remaining open web clients.
* Improved overall service caching.
* Added: Support for `Cloud-Identity` licenses for `Get-GSUserLicense`
* Added: `OutputType` for all applicable Helper functions (i.e. `Add-GSUserIm`)

## 2.26.1

* [Issue #172](https://github.com/scrthq/PSGSuite/issues/172)
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.26.1'
ModuleVersion = '2.26.2'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down Expand Up @@ -95,7 +95,7 @@
# Prerelease = '-alpha'

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'GSuite', 'Google', 'Apps', 'API', 'Drive', 'Gmail', 'Admin', 'Automation', 'PSEdition_Core', 'PSEdition_Desktop'
Tags = 'GSuite', 'Google', 'Apps', 'API', 'Drive', 'Gmail', 'Admin', 'Automation', 'PSEdition_Core', 'PSEdition_Desktop', 'Windows', 'Linux', 'Mac'

# A URL to the license for this module.
LicenseUri = 'https://github.com/scrthq/PSGSuite/blob/master/LICENSE'
Expand Down
70 changes: 47 additions & 23 deletions PSGSuite/Private/ListPrivate/Get-GSUserLicenseListPrivate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ function Get-GSUserLicenseListPrivate {
Param
(
[parameter(Mandatory = $false)]
[ValidateSet("Google-Apps","Google-Drive-storage","Google-Vault")]
[ValidateSet("Google-Apps","Google-Drive-storage","Google-Vault","Cloud-Identity","Cloud-Identity-Premium")]
[string[]]
$ProductID = @("Google-Apps","Google-Drive-storage","Google-Vault"),
$ProductID = @("Google-Apps","Google-Drive-storage","Google-Vault","Cloud-Identity","Cloud-Identity-Premium"),
[parameter(Mandatory = $false)]
[Alias("SkuId")]
[ValidateSet("G-Suite-Enterprise","Google-Apps-Unlimited","Google-Apps-For-Business","Google-Apps-For-Postini","Google-Apps-Lite","Google-Drive-storage-20GB","Google-Drive-storage-50GB","Google-Drive-storage-200GB","Google-Drive-storage-400GB","Google-Drive-storage-1TB","Google-Drive-storage-2TB","Google-Drive-storage-4TB","Google-Drive-storage-8TB","Google-Drive-storage-16TB","Google-Vault","Google-Vault-Former-Employee","1010020020")]
[ValidateSet("Cloud-Identity","Cloud-Identity-Premium","Drive-Enterprise","G-Suite-Enterprise","Google-Apps-Unlimited","Google-Apps-For-Business","Google-Apps-For-Postini","Google-Apps-Lite","Google-Drive-storage-20GB","Google-Drive-storage-50GB","Google-Drive-storage-200GB","Google-Drive-storage-400GB","Google-Drive-storage-1TB","Google-Drive-storage-2TB","Google-Drive-storage-4TB","Google-Drive-storage-8TB","Google-Drive-storage-16TB","Google-Vault","Google-Vault-Former-Employee","1010020020","1010060001","1010010001","1010050001")]
[string]
$License,
[parameter(Mandatory = $false)]
Expand All @@ -25,33 +25,57 @@ function Get-GSUserLicenseListPrivate {
$service = New-GoogleService @serviceParams
if ($License) {
$ProductID = @{
'1010020020' = 'Google-Apps'
'G-Suite-Enterprise' = 'Google-Apps'
'Google-Apps-Unlimited' = 'Google-Apps'
'Google-Apps-For-Business' = 'Google-Apps'
'Google-Apps-For-Postini' = 'Google-Apps'
'Google-Apps-Lite' = 'Google-Apps'
'Google-Vault' = 'Google-Vault'
'Google-Vault-Former-Employee' = 'Google-Vault'
'Google-Drive-storage-20GB' = 'Google-Drive-storage'
'Google-Drive-storage-50GB' = 'Google-Drive-storage'
'Google-Drive-storage-200GB' = 'Google-Drive-storage'
'Google-Drive-storage-400GB' = 'Google-Drive-storage'
'Google-Drive-storage-1TB' = 'Google-Drive-storage'
'Google-Drive-storage-2TB' = 'Google-Drive-storage'
'Google-Drive-storage-4TB' = 'Google-Drive-storage'
'Google-Drive-storage-8TB' = 'Google-Drive-storage'
'Google-Drive-storage-16TB' = 'Google-Drive-storage'
'Cloud-Identity' = @('101001') # Cloud-Identity
'1010010001' = @('101001') # Cloud-Identity
'Cloud-Identity-Premium' = @('101005') # Cloud-Identity-Premium
'1010050001' = @('101005') # Cloud-Identity-Premium
'1010020020' = @('Google-Apps') # G-Suite-Enterprise
'1010060001' = @('Google-Apps') # Drive-Enterprise
'G-Suite-Enterprise' = @('Google-Apps')
'Google-Apps-Unlimited' = @('Google-Apps')
'Google-Apps-For-Business' = @('Google-Apps')
'Google-Apps-For-Postini' = @('Google-Apps')
'Google-Apps-Lite' = @('Google-Apps')
'Google-Vault' = @('Google-Vault')
'Google-Vault-Former-Employee' = @('Google-Vault')
'Google-Drive-storage-20GB' = @('Google-Drive-storage')
'Google-Drive-storage-50GB' = @('Google-Drive-storage')
'Google-Drive-storage-200GB' = @('Google-Drive-storage')
'Google-Drive-storage-400GB' = @('Google-Drive-storage')
'Google-Drive-storage-1TB' = @('Google-Drive-storage')
'Google-Drive-storage-2TB' = @('Google-Drive-storage')
'Google-Drive-storage-4TB' = @('Google-Drive-storage')
'Google-Drive-storage-8TB' = @('Google-Drive-storage')
'Google-Drive-storage-16TB' = @('Google-Drive-storage')
}[$License]
}
$response = @()
}
Process {
try {
foreach ($prodId in $ProductID) {
switch ($prodId) {
"Cloud-Identity" {
$prodId = "101001"
}
"Cloud-Identity-Premium" {
$prodId = "101005"
}
}
if ($License) {
if ($License -eq "G-Suite-Enterprise") {
$License = "1010020020"
switch ($License) {
"G-Suite-Enterprise" {
$License = "1010020020"
}
"Drive-Enterprise" {
$License = "1010060001"
}
"Cloud-Identity" {
$License = "1010010001"
}
"Cloud-Identity-Premium" {
$License = "1010050001"
}
}
$request = $service.LicenseAssignments.ListForProductAndSku($prodId,$License,$Script:PSGSuite.Domain)
}
Expand Down Expand Up @@ -89,4 +113,4 @@ function Get-GSUserLicenseListPrivate {
}
}
}
}
}
37 changes: 37 additions & 0 deletions PSGSuite/Public/Authentication/Clear-PSGSuiteServiceCache.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function Clear-PSGSuiteServiceCache {
<#
.SYNOPSIS
Clears the dictionary of cached service objects created with New-GoogleService.
.DESCRIPTION
Clears the dictionary of cached service objects created with New-GoogleService.
.EXAMPLE
Clear-PSGSuiteServiceCache
#>
[CmdletBinding()]
Param ()
Begin{
if (-not $script:_PSGSuiteSessions) {
$script:_PSGSuiteSessions = @{}
}
$toRemove = @()
}
Process {
if (-not $script:_PSGSuiteSessions.Keys.Count) {
Write-Verbose "There are no current cached sessions to clear!"
}
else {
foreach ($key in $script:_PSGSuiteSessions.Keys) {
Write-Verbose "Clearing cached session with key: $key"
$script:_PSGSuiteSessions[$key].Service.Dispose()
$toRemove += $key
}
}
}
End {
foreach ($key in $toRemove) {
$script:_PSGSuiteSessions.Remove($key)
}
}
}
12 changes: 11 additions & 1 deletion PSGSuite/Public/Authentication/Get-PSGSuiteServiceCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ function Get-PSGSuiteServiceCache {
$SessionKey = @($User,$ServiceType,$(($Scope | Sort-Object) -join ";")) -join ";"
.PARAMETER IncludeKeys
If $true, returns the full service cache dictionary including keys.
Defaults to $false.
.EXAMPLE
Get-PSGSuiteServiceCache
#>
Expand All @@ -26,6 +31,11 @@ function Get-PSGSuiteServiceCache {
}
Process {
Write-Verbose "Getting cached session list"
$script:_PSGSuiteSessions.Values
if ($IncludeKeys) {
$script:_PSGSuiteSessions
}
else {
$script:_PSGSuiteSessions.Values
}
}
}
5 changes: 3 additions & 2 deletions PSGSuite/Public/Authentication/New-GoogleService.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function New-GoogleService {
Write-Verbose "Using matching cached service for user '$User'"
$script:_PSGSuiteSessions[$sessionKey].Acknowledged = $true
}
$script:_PSGSuiteSessions[$sessionKey].LastUsed = Get-Date
$script:_PSGSuiteSessions[$sessionKey] | Select-Object -ExpandProperty Service
}
else {
Expand Down Expand Up @@ -96,12 +97,12 @@ function New-GoogleService {
ApplicationName = "PSGSuite - $env:USERNAME"
}
)
$issued = Get-Date
$script:_PSGSuiteSessions[$sessionKey] = ([PSCustomObject]@{
User = $User
Scope = $Scope
Service = $svc
Issued = $issued
Issued = Get-Date
LastUsed = Get-Date
Acknowledged = $false
})
return $svc
Expand Down
24 changes: 19 additions & 5 deletions PSGSuite/Public/Drive/Get-GSDriveFileList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function Get-GSDriveFileList {
.PARAMETER Corpora
Comma-separated list of bodies of items (files/documents) to which the query applies. Supported bodies are 'User', 'Domain', 'TeamDrive' and 'AllTeamDrives'. 'AllTeamDrives' must be combined with 'User'; all other values must be used in isolation. Prefer 'User' or 'TeamDrive' to 'AllTeamDrives' for efficiency.
.PARAMETER Fields
The specific fields to fetch for the listed files.
.PARAMETER Spaces
A comma-separated list of spaces to query within the corpus. Supported values are 'Drive', 'AppDataFolder' and 'Photos'.
Expand Down Expand Up @@ -64,6 +67,9 @@ function Get-GSDriveFileList {
[Switch]
$IncludeTeamDriveItems,
[parameter(Mandatory = $false)]
[String[]]
$Fields = @('files','kind','nextPageToken'),
[parameter(Mandatory = $false)]
[ValidateSet('user','domain','teamDrive')]
[String]
$Corpora,
Expand Down Expand Up @@ -96,6 +102,9 @@ function Get-GSDriveFileList {
$PSBoundParameters['Filter'] = @("'$ParentFolderId' in parents")
}
}
if ($Fields -notcontains '*' -and $Fields -notcontains 'nextPageToken') {
$Fields += 'nextPageToken'
}
}
Process {
if ($User -ceq 'me') {
Expand All @@ -113,7 +122,6 @@ function Get-GSDriveFileList {
try {
$request = $service.Files.List()
$request.SupportsTeamDrives = $true
$request.Fields = 'files,kind,nextPageToken'
if ($PageSize) {
$request.PageSize = $PageSize
}
Expand All @@ -123,6 +131,9 @@ function Get-GSDriveFileList {
$FilterFmt = ($PSBoundParameters[$key] -join " and ") -replace " -eq ","=" -replace " -like ",":" -replace " -match ",":" -replace " -contains ",":" -creplace "'True'","True" -creplace "'False'","False" -replace " -in "," in " -replace " -le ",'<=' -replace " -ge ",">=" -replace " -gt ",'>' -replace " -lt ",'<' -replace " -ne ","!=" -replace " -and "," and " -replace " -or "," or " -replace " -not "," not "
$request.Q = $FilterFmt
}
Fields {
$request.Fields = "$($Fields -join ",")"
}
Spaces {
$request.$key = $($PSBoundParameters[$key] -join ",")
}
Expand All @@ -133,12 +144,15 @@ function Get-GSDriveFileList {
}
}
}
if ($FilterFmt) {
Write-Verbose "Getting all Drive Files for User '$User' matching Filter: $FilterFmt"
$baseVerbose = "Getting"
if ($Fields) {
$baseVerbose += " Fields [$($Fields -join ",")] of"
}
else {
Write-Verbose "Getting all Drive Files for User '$User'"
$baseVerbose += " all Drive Files for User '$User'"
if ($FilterFmt) {
$baseVerbose += " matching Filter: $FilterFmt"
}
Write-Verbose $baseVerbose
[int]$i = 1
do {
$result = $request.Execute()
Expand Down
2 changes: 1 addition & 1 deletion PSGSuite/Public/Drive/Start-GSDriveFileUpload.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function Start-GSDriveFileUpload {
if ($Description) {
$body.Description = $Description
}
$stream = New-Object 'System.IO.FileStream' $detPart.FullName,([System.IO.FileMode]::Open),([System.IO.FileAccess]::Read),([System.IO.FileShare]::Delete + [System.IO.FileShare]::ReadWrite)
$stream = New-Object 'System.IO.FileStream' $detPart.FullName,([System.IO.FileMode]::Open),([System.IO.FileAccess]::Read),([System.IO.FileShare]"Delete, ReadWrite")
$request = $service.Files.Create($body,$stream,$contentType)
$request.QuotaUser = $User
$request.SupportsTeamDrives = $true
Expand Down
8 changes: 5 additions & 3 deletions PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ function New-GSGmailSMIMEInfo {
$body.$key = (New-Object PSCredential "user",$PSBoundParameters[$key]).GetNetworkCredential().Password
}
Pkcs12 {
$p12String = Convert-Base64 -From NormalString -To WebSafeBase64String -String "$([System.IO.File]::ReadAllText((Resolve-Path $PSBoundParameters[$key]).Path))"
$body.$key = $p12String
###$p12String = Convert-Base64 -From NormalString -To WebSafeBase64String -String "$([System.IO.File]::ReadAllText((Resolve-Path $PSBoundParameters[$key]).Path))"
###$body.$key = $p12String
$body.$key = [string]([System.IO.File]::ReadAllBytes((Resolve-Path $PSBoundParameters[$key]).Path))
}
Default {
$body.$prop = $PSBoundParameters[$prop]
$body.$key = $PSBoundParameters[$key]
}
}
}
Write-Verbose "Adding new S/MIME of SendAsEmail '$SendAsEmail' for user '$User' using Certificate '$Pkcs12'"
Write-Verbose "Pkcs12: $($body.Pkcs12)"
$request = $service.Users.Settings.SendAs.SmimeInfo.Insert($body,$User,$SendAsEmail)
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
}
Expand Down
29 changes: 15 additions & 14 deletions PSGSuite/Public/Helpers/Add-GSEventAttendee.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,44 @@ function Add-GSEventAttendee {
<#
.SYNOPSIS
Adds an event attendee to a calendar event
.DESCRIPTION
Adds an event attendee to a calendar event
.PARAMETER Email
The email address of the attendee
.PARAMETER AdditionalGuests
How many additional guests, if any
.PARAMETER Comment
Attendee comment
.PARAMETER DisplayName
The attendee's name, if available
.PARAMETER Optional
Whether this is an optional attendee
.PARAMETER Organizer
Whether the attendee is the organizer of the event
.PARAMETER Resource
Whether the attendee is a resource
.PARAMETER ResponseStatus
The attendee's response status.
Possible values are:
The attendee's response status.
Possible values are:
* "NeedsAction": The attendee has not responded to the invitation.
* "Declined": The attendee has declined the invitation.
* "Tentative": The attendee has tentatively accepted the invitation.
* "Accepted": The attendee has accepted the invitation
.PARAMETER InputObject
Used for pipeline input of an existing UserAddress object to strip the extra attributes and prevent errors
#>
[OutputType('Google.Apis.Calendar.v3.Data.EventAttendee')]
[CmdletBinding(DefaultParameterSetName = "InputObject")]
Param
(
Expand Down Expand Up @@ -114,4 +115,4 @@ function Add-GSEventAttendee {
}
}
}
}
}
Loading

0 comments on commit 453728f

Please sign in to comment.