Skip to content

Commit

Permalink
!deploy v2.22.1 - updates from PR #141 from @dwrusse
Browse files Browse the repository at this point in the history
## 2.22.1

* [PR #141](#141) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
  * Added: `Remove-GSDriveFile`
  * Updated: `Get-GSCalendarSubscription` to add support for `List()` requests and added the `ShowHidden` & `ShowDeleted` parameters.
  • Loading branch information
scrthq authored Dec 29, 2018
2 parents 08b7958 + 053b9db commit 5ae82c6
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

* [Changelog](#changelog)
* [2.22.1](#2221)
* [2.22.0](#2220)
* [2.21.3](#2213)
* [2.21.2](#2212)
Expand Down Expand Up @@ -69,6 +70,12 @@

***

## 2.22.1

* [PR #141](https://github.com/scrthq/PSGSuite/pull/141) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
* Added: `Remove-GSDriveFile`
* Updated: `Get-GSCalendarSubscription` to add support for `List()` requests and added the `ShowHidden` & `ShowDeleted` parameters.

## 2.22.0

* Miscellaneous: _Config management and portability updates_
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.22.0'
ModuleVersion = '2.22.1'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
28 changes: 26 additions & 2 deletions PSGSuite/Public/Calendar/Get-GSCalendarSubscription.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ function Get-GSCalendarSubscription {
.PARAMETER CalendarID
The calendar ID of the calendar you would like to get info for. If left blank, returns the list of calendars the user is subscribed to.
.PARAMETER ShowDeleted
Whether to include deleted calendar list entries in the result. Optional. The default is False.
.PARAMETER ShowHidden
Whether to show hidden entries. Optional. The default is False.
.EXAMPLE
Get-GSCalendarSubscription
Expand All @@ -30,7 +36,13 @@ function Get-GSCalendarSubscription {
$User = $Script:PSGSuite.AdminEmail,
[parameter(Mandatory = $false,Position = 1)]
[String[]]
$CalendarId
$CalendarId,
[Parameter(Mandatory = $false)]
[Switch]
$ShowDeleted,
[Parameter(Mandatory = $false)]
[Switch]
$ShowHidden
)
Begin {
if ($User -ceq 'me') {
Expand Down Expand Up @@ -68,7 +80,19 @@ function Get-GSCalendarSubscription {
try {
Write-Verbose "Getting subscribed calendar list for user '$User'"
$request = $service.CalendarList.List()
$request.Execute() | Select-Object -ExpandProperty Items
foreach ($key in $PSBoundParameters.Keys | Where-Object {$request.PSObject.Properties.Name -contains $_}) {
$request.$key = $PSBoundParameters[$key]
}
[int]$i = 1
do {
$result = $request.Execute()
$result.Items | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
$request.PageToken = $result.NextPageToken
[int]$retrieved = ($i + $result.Items.Count) - 1
Write-Verbose "Retrieved $retrieved Calendar Subscriptions..."
[int]$i = $i + $result.Items.Count
}
until (-not $result.NextPageToken)
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
Expand Down
68 changes: 68 additions & 0 deletions PSGSuite/Public/Drive/Remove-GSDriveFile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
function Remove-GSDriveFile {
<#
.SYNOPSIS
Deletes a Drive file
.DESCRIPTION
Deletes a Drive file
.PARAMETER FileId
The unique Id of the file to get
.PARAMETER User
The email or unique Id of the owner of the Drive file
Defaults to the AdminEmail user
.EXAMPLE
Remove-GSDriveFile -User [email protected] -FileId '1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976'
Deletes the file with ID 1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976 from the user [email protected]'s Drive
#>
[cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = "High")]
Param
(
[parameter(Mandatory = $true, Position = 0)]
[String[]]
$FileId,
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[Alias('Owner', 'PrimaryEmail', 'UserKey', 'Mail')]
[string]
$User = $Script:PSGSuite.AdminEmail
)
Begin {
if ($User -ceq 'me') {
$User = $Script:PSGSuite.AdminEmail
}
elseif ($User -notlike "*@*.*") {
$User = "$($User)@$($Script:PSGSuite.Domain)"
}
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/drive'
ServiceType = 'Google.Apis.Drive.v3.DriveService'
User = $User
}
$service = New-GoogleService @serviceParams
}
Process {
foreach ($file in $FileId) {
try {
if ($PSCmdlet.ShouldProcess("Deleting File Id '$file' from user '$User'")) {
Write-Verbose "Deleting File Id '$file' from user '$User'"
$request = $service.Files.Delete($file)
$request.SupportsTeamDrives = $true
$request.Execute()
Write-Verbose "File Id '$file' successfully deleted from user '$User'"
}
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ Update-GSSheetValue Export-GSSheet

### Most recent changes

#### 2.22.1

* [PR #141](https://github.com/scrthq/PSGSuite/pull/141) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
* Added: `Remove-GSDriveFile`
* Updated: `Get-GSCalendarSubscription` to add support for `List()` requests and added the `ShowHidden` & `ShowDeleted` parameters.

#### 2.22.0

* Miscellaneous: _Config management and portability updates_
Expand Down

0 comments on commit 5ae82c6

Please sign in to comment.