Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.22.1 #141

Merged
merged 11 commits into from
Dec 29, 2018
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
* [Functions Aliased](#functions-aliased)

***
## 2.22.1

* Added Remove-GSDriveFile
* Get-GSCalendarSubscription: Added support for more than 100 results, ShowHidden & ShowDeleted parameters.

## 2.22.0

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 $_
}
}
}
}
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ Update-GSSheetValue Export-GSSheet

### Most recent changes

## 2.22.1

* Added Remove-GSDriveFile
* Get-GSCalendarSubscription: Added support for more than 100 results, ShowHidden & ShowDeleted parameters.

#### 2.22.0

* Miscellaneous: _Config management and portability updates_
Expand Down