diff --git a/CHANGELOG.md b/CHANGELOG.md index ff87c10c..d7ca9c9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ * [PSGSuite - ChangeLog](#psgsuite---changelog) + * [2.33.1 - 2019-10-06](#2331---2019-10-06) * [2.33.0 - 2019-09-26](#2330---2019-09-26) * [2.32.3 - 2019-09-18](#2323---2019-09-18) * [2.32.2 - 2019-09-15](#2322---2019-09-15) @@ -101,6 +102,21 @@ # PSGSuite - ChangeLog +## 2.33.1 - 2019-10-06 + +* [Issue #235](https://github.com/scrthq/PSGSuite/issues/235) + * Removed: `Name` parameter from `Start-GSDriveFileUpload` as it was unused in the function and doesnt make sense when uploading an array of files. +* [Issue #238](https://github.com/scrthq/PSGSuite/issues/238) + * Added: `Get-GSDataTransfer` to Get/List current Data Transfers +* [Issue #239](https://github.com/scrthq/PSGSuite/issues/239) + * Removed: `Update-GSResource` `Id` parameter as it was non-applicable (duplicate of `ResourceId` and not writable per API docs) + * Cleaned up function help and examples to match changes +* [Issue #240](https://github.com/scrthq/PSGSuite/issues/240) + * Fixed: `Get-GSCalendar` now properly resolves single calendar metadata retrieval and passes List requests to `Get-GSCalendarSubscription` since the `Calendars` service does not support List requests. +* Miscellaneous + * Updated Google .NET SDKs to latest versions + * Cleaned up build.ps1 script + ## 2.33.0 - 2019-09-26 * [Issue #236](https://github.com/scrthq/PSGSuite/issues/236) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 151a48f7..4cc62846 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,16 +3,16 @@ * [Contributing to PSGSuite](#contributing-to-psgsuite) - * [Git and Pull requests](#git-and-pull-requests) - * [Overview](#overview) - * [Step by Step (High-Level)](#step-by-step-high-level) - * [Contributing Guidelines](#contributing-guidelines) - * [Updating the Wiki](#updating-the-wiki) - * [Getting Started](#getting-started) - * [Enabling Debug Mode](#enabling-debug-mode) - * [Google .NET SDK Documentation](#google-net-sdk-documentation) - * [.NET/API Documentation Links](#netapi-documentation-links) - * [Keeping in Touch](#keeping-in-touch) + * [Git and Pull requests](#git-and-pull-requests) + * [Overview](#overview) + * [Step by Step (High-Level)](#step-by-step-high-level) + * [Contributing Guidelines](#contributing-guidelines) + * [Updating the Wiki](#updating-the-wiki) + * [Getting Started](#getting-started) + * [Enabling Debug Mode](#enabling-debug-mode) + * [Google .NET SDK Documentation](#google-net-sdk-documentation) + * [.NET/API Documentation Links](#netapi-documentation-links) + * [Keeping in Touch](#keeping-in-touch) @@ -129,6 +129,9 @@ Here are some links to the most commonly used SDK's and API's in PSGSuite: * **Contacts API - To be replaced soon with People API** * [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/contacts/v1/csharp/latest/) * [API Documentation](https://developers.google.com/contacts/v3/reference) +* **Data Transfer API** + * [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/admin/datatransfer_v1/csharp/latest/) + * [API Documentation](https://developers.google.com/admin-sdk/data-transfer/v1/reference) * **Drive Activity API v2** * [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/driveactivity/v2/csharp/latest/) * [API Documentation](https://developers.google.com/drive/activity/v2/reference/rest/) diff --git a/PSGSuite/PSGSuite.psd1 b/PSGSuite/PSGSuite.psd1 index 3c68ef20..d41bc804 100644 --- a/PSGSuite/PSGSuite.psd1 +++ b/PSGSuite/PSGSuite.psd1 @@ -12,7 +12,7 @@ RootModule = 'PSGSuite.psm1' # Version number of this module. - ModuleVersion = '2.33.0' + ModuleVersion = '2.33.1' # ID used to uniquely identify this module GUID = '9d751152-e83e-40bb-a6db-4c329092aaec' diff --git a/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 b/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 index c651e136..8f0e9051 100644 --- a/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 +++ b/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 @@ -1,10 +1,10 @@ function Get-GSCalendar { <# .SYNOPSIS - Gets the calendars for a user + Returns metadata for a calendar. If no calendar ID is specified, returns the list of calendar subscriptions via Get-GSCalendarSubscription .DESCRIPTION - Gets the calendars for a user + Returns metadata for a calendar. If no calendar ID is specified, returns the list of calendar subscriptions via Get-GSCalendarSubscription .PARAMETER CalendarId The Id of the calendar you would like to get. @@ -49,19 +49,19 @@ function Get-GSCalendar { https://psgsuite.io/Function%20Help/Calendar/Get-GSCalendar/ .LINK - https://developers.google.com/calendar/v3/reference/calendarList/get + https://developers.google.com/calendar/v3/reference/calendars/get .LINK https://developers.google.com/calendar/v3/reference/calendarList/list #> - [OutputType('Google.Apis.Calendar.v3.Data.CalendarListEntry')] + [OutputType('Google.Apis.Calendar.v3.Data.Calendar')] [cmdletbinding(DefaultParameterSetName = "List")] - Param - ( - [parameter(Mandatory = $true,Position = 0,ParameterSetName = "Get")] + Param ( + [parameter(Mandatory,Position = 0,ValueFromPipelineByPropertyName,ParameterSetName = "Get")] + [Alias('Id')] [String[]] $CalendarId, - [parameter(Mandatory = $false,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)] + [parameter(ValueFromPipelineByPropertyName)] [Alias("PrimaryEmail","UserKey","Mail")] [ValidateNotNullOrEmpty()] [String[]] @@ -89,21 +89,21 @@ function Get-GSCalendar { $SyncToken ) Process { - foreach ($U in $User) { - if ($U -ceq 'me') { - $U = $Script:PSGSuite.AdminEmail - } - elseif ($U -notlike "*@*.*") { - $U = "$($U)@$($Script:PSGSuite.Domain)" - } - $serviceParams = @{ - Scope = 'https://www.googleapis.com/auth/calendar' - ServiceType = 'Google.Apis.Calendar.v3.CalendarService' - User = $U - } - $service = New-GoogleService @serviceParams - switch ($PSCmdlet.ParameterSetName) { - Get { + switch ($PSCmdlet.ParameterSetName) { + Get { + foreach ($U in $User) { + if ($U -ceq 'me') { + $U = $Script:PSGSuite.AdminEmail + } + elseif ($U -notlike "*@*.*") { + $U = "$($U)@$($Script:PSGSuite.Domain)" + } + $serviceParams = @{ + Scope = 'https://www.googleapis.com/auth/calendar' + ServiceType = 'Google.Apis.Calendar.v3.CalendarService' + User = $U + } + $service = New-GoogleService @serviceParams foreach ($calId in $CalendarId) { try { $request = $service.Calendars.Get($calId) @@ -120,52 +120,9 @@ function Get-GSCalendar { } } } - List { - try { - $request = $service.Calendars.List() - foreach ($key in $PSBoundParameters.Keys | Where-Object {$_ -ne 'CalendarId'}) { - if ($request.PSObject.Properties.Name -contains $key) { - $request.$key = $PSBoundParameters[$key] - } - } - 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) - $PageSize = $Limit - } - $request.MaxResults = $PageSize - Write-Verbose "Getting Calendars for user '$U'" - [int]$i = 1 - $overLimit = $false - do { - $result = $request.Execute() - $result.Items | Add-Member -MemberType NoteProperty -Name 'User' -Value $U -PassThru - if ($result.NextPageToken) { - $request.PageToken = $result.NextPageToken - } - [int]$retrieved = ($i + $result.Items.Count) - 1 - Write-Verbose "Retrieved $retrieved Calendars..." - if ($Limit -gt 0 -and $retrieved -eq $Limit) { - Write-Verbose "Limit reached: $Limit" - $overLimit = $true - } - elseif ($Limit -gt 0 -and ($retrieved + $PageSize) -gt $Limit) { - $newPS = $Limit - $retrieved - Write-Verbose ("Reducing PageSize from {0} to {1} to meet limit with next page" -f $PageSize,$newPS) - $request.MaxResults = $newPS - } - [int]$i = $i + $result.Items.Count - } - until ($overLimit -or !$result.NextPageToken) - } - catch { - if ($ErrorActionPreference -eq 'Stop') { - $PSCmdlet.ThrowTerminatingError($_) - } - else { - Write-Error $_ - } - } - } + } + List { + Get-GSCalendarSubscription @PSBoundParameters } } } diff --git a/PSGSuite/Public/Calendar/Get-GSCalendarSubscription.ps1 b/PSGSuite/Public/Calendar/Get-GSCalendarSubscription.ps1 index 051e3eee..2acf8fff 100644 --- a/PSGSuite/Public/Calendar/Get-GSCalendarSubscription.ps1 +++ b/PSGSuite/Public/Calendar/Get-GSCalendarSubscription.ps1 @@ -14,12 +14,30 @@ 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 MinAccessRole + The minimum access role for the user in the returned entries. Optional. The default is no restriction. + + .PARAMETER PageSize + Maximum number of entries returned on one result page. The page size can never be larger than 250 entries. + + .PARAMETER Limit + The maximum amount of results you want returned. Exclude or set to 0 to return all results + .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. + .PARAMETER SyncToken + Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. + + If only read-only fields such as calendar properties or ACLs have changed, the entry won't be returned. All entries deleted and hidden since the previous list request will always be in the result set and it is not allowed to set showDeleted neither showHidden to False. + + To ensure client state consistency minAccessRole query parameter cannot be specified together with nextSyncToken. If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken. Learn more about incremental synchronization. + + Optional. The default is to return all entries. + .EXAMPLE Get-GSCalendarSubscription @@ -27,47 +45,112 @@ function Get-GSCalendarSubscription { .LINK https://psgsuite.io/Function%20Help/Calendar/Get-GSCalendarSubscription/ + + .LINK + https://developers.google.com/calendar/v3/reference/calendarList/get + + .LINK + https://developers.google.com/calendar/v3/reference/calendarList/list #> [OutputType('Google.Apis.Calendar.v3.Data.CalendarListEntry')] - [cmdletbinding()] - Param - ( - [parameter(Mandatory = $false,Position = 0)] + [cmdletbinding(DefaultParameterSetName = 'List')] + Param ( + [parameter(Mandatory,Position = 0,ValueFromPipelineByPropertyName,ParameterSetName = "Get")] + [Alias('Id')] + [String[]] + $CalendarId, + [parameter(ValueFromPipelineByPropertyName)] [Alias("PrimaryEmail","UserKey","Mail")] [ValidateNotNullOrEmpty()] - [String] - $User = $Script:PSGSuite.AdminEmail, - [parameter(Mandatory = $false,Position = 1)] [String[]] - $CalendarId, - [Parameter(Mandatory = $false)] - [Switch] + $User = $Script:PSGSuite.AdminEmail, + [parameter(ParameterSetName = "List")] + [Google.Apis.Calendar.v3.CalendarListResource+ListRequest+MinAccessRoleEnum] + $MinAccessRole, + [parameter(ParameterSetName = "List")] + [Alias('MaxResults')] + [ValidateRange(1,250)] + [Int] + $PageSize = 250, + [parameter(ParameterSetName = "List")] + [Alias('First')] + [Int] + $Limit = 0, + [parameter(ParameterSetName = "List")] + [switch] $ShowDeleted, - [Parameter(Mandatory = $false)] - [Switch] - $ShowHidden + [parameter(ParameterSetName = "List")] + [switch] + $ShowHidden, + [parameter(ParameterSetName = "List")] + [String] + $SyncToken ) - Begin { - if ($User -ceq 'me') { - $User = $Script:PSGSuite.AdminEmail - } - elseif ($User -notlike "*@*.*") { - $User = "$($User)@$($Script:PSGSuite.Domain)" - } - $serviceParams = @{ - Scope = 'https://www.googleapis.com/auth/calendar' - ServiceType = 'Google.Apis.Calendar.v3.CalendarService' - User = $User - } - $service = New-GoogleService @serviceParams - } Process { - if ($PSBoundParameters.Keys -contains 'CalendarId') { - foreach ($calId in $CalendarID) { + foreach ($U in $User) { + if ($U -ceq 'me') { + $U = $Script:PSGSuite.AdminEmail + } + elseif ($U -notlike "*@*.*") { + $U = "$($U)@$($Script:PSGSuite.Domain)" + } + $serviceParams = @{ + Scope = 'https://www.googleapis.com/auth/calendar' + ServiceType = 'Google.Apis.Calendar.v3.CalendarService' + User = $U + } + $service = New-GoogleService @serviceParams + if ($PSCmdlet.ParameterSetName -eq 'Get') { + foreach ($calId in $CalendarID) { + try { + Write-Verbose "Getting subscribed calendar '$($calId)' for user '$U'" + $request = $service.CalendarList.Get($calId) + $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $U -PassThru + } + catch { + if ($ErrorActionPreference -eq 'Stop') { + $PSCmdlet.ThrowTerminatingError($_) + } + else { + Write-Error $_ + } + } + } + } + else { try { - Write-Verbose "Getting subscribed calendar '$($calId)' for user '$User'" - $request = $service.CalendarList.Get($calId) - $request.Execute() + $request = $service.CalendarList.List() + foreach ($key in $PSBoundParameters.Keys | Where-Object {$request.PSObject.Properties.Name -contains $_}) { + $request.$key = $PSBoundParameters[$key] + } + 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) + $PageSize = $Limit + } + $request.MaxResults = $PageSize + Write-Verbose "Getting CalendarList for user '$U'" + [int]$i = 1 + $overLimit = $false + do { + $result = $request.Execute() + $result.Items | Add-Member -MemberType NoteProperty -Name 'User' -Value $U -PassThru + if ($result.NextPageToken) { + $request.PageToken = $result.NextPageToken + } + [int]$retrieved = ($i + $result.Items.Count) - 1 + Write-Verbose "Retrieved $retrieved Calendars..." + if ($Limit -gt 0 -and $retrieved -eq $Limit) { + Write-Verbose "Limit reached: $Limit" + $overLimit = $true + } + elseif ($Limit -gt 0 -and ($retrieved + $PageSize) -gt $Limit) { + $newPS = $Limit - $retrieved + Write-Verbose ("Reducing PageSize from {0} to {1} to meet limit with next page" -f $PageSize,$newPS) + $request.MaxResults = $newPS + } + [int]$i = $i + $result.Items.Count + } + until ($overLimit -or !$result.NextPageToken) } catch { if ($ErrorActionPreference -eq 'Stop') { @@ -79,32 +162,5 @@ function Get-GSCalendarSubscription { } } } - else { - try { - Write-Verbose "Getting subscribed calendar list for user '$User'" - $request = $service.CalendarList.List() - 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') { - $PSCmdlet.ThrowTerminatingError($_) - } - else { - Write-Error $_ - } - } - } } } diff --git a/PSGSuite/Public/Data Transfer/Get-GSDataTransfer.ps1 b/PSGSuite/Public/Data Transfer/Get-GSDataTransfer.ps1 new file mode 100644 index 00000000..41c3ce2a --- /dev/null +++ b/PSGSuite/Public/Data Transfer/Get-GSDataTransfer.ps1 @@ -0,0 +1,126 @@ +function Get-GSDataTransfer { + <# + .SYNOPSIS + Gets the list of Data Transfers + + .DESCRIPTION + Gets the list of Data Transfers + + .PARAMETER DataTransferId + The Id of the Data Transfer you would like to return info for specifically. Exclude to return the full list + + .PARAMETER Status + Status of the transfer. + + .PARAMETER NewOwnerUserId + Destination user's profile ID. + + .PARAMETER OldOwnerUserId + Source user's profile ID. + + .PARAMETER CustomerId + Immutable ID of the G Suite account. + + .PARAMETER PageSize + PageSize of the result set. + + Defaults to 500 (although it's typically a much smaller number for most Customers) + + .PARAMETER Limit + The maximum amount of results you want returned. Exclude or set to 0 to return all results + + .EXAMPLE + Get-GSDataTransfer + + Gets the list of current Data Transfers + #> + [OutputType('Google.Apis.Admin.DataTransfer.datatransfer_v1.Data.ApplicationDataTransfer')] + [cmdletbinding(DefaultParameterSetName = 'List')] + Param ( + [parameter(Mandatory,Position = 0,ParameterSetName = 'Get')] + [String[]] + $DataTransferId, + [parameter(ParameterSetName = 'List')] + [String] + $Status, + [parameter(ParameterSetName = 'List')] + [String] + $NewOwnerUserId, + [parameter(ParameterSetName = 'List')] + [String] + $OldOwnerUserId, + [parameter(ParameterSetName = 'List')] + [String] + $CustomerId = $Script:PSGSuite.CustomerID, + [parameter(ParameterSetName = 'List')] + [ValidateRange(1,500)] + [Int] + $PageSize = 500, + [parameter(ParameterSetName = 'List')] + [Alias('First')] + [Int] + $Limit = 0 + ) + Process { + $serviceParams = @{ + Scope = 'https://www.googleapis.com/auth/admin.datatransfer' + ServiceType = 'Google.Apis.Admin.DataTransfer.datatransfer_v1.DataTransferService' + } + $service = New-GoogleService @serviceParams + try { + if ($PSCmdlet.ParameterSetName -eq 'Get') { + foreach ($I in $DataTransferId) { + $request = $service.Transfers.Get($I) + $request.Execute() + } + } + else { + $request = $service.Transfers.List() + $request.CustomerId = $CustomerId + 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) + $PageSize = $Limit + } + $request.MaxResults = $PageSize + foreach ($prop in @('NewOwnerUserId','OldOwnerUserId','Status')) { + if ($PSBoundParameters.ContainsKey($prop)) { + $request.$prop = $PSBoundParameters[$prop] + } + } + Write-Verbose "Getting Data Transfer list" + $response = @() + [int]$i = 1 + $overLimit = $false + do { + $result = $request.Execute() + $response += $result.DataTransfers + if ($result.NextPageToken) { + $request.PageToken = $result.NextPageToken + } + [int]$retrieved = ($i + $result.DataTransfers.Count) - 1 + Write-Verbose "Retrieved $retrieved Data Transfers..." + if ($Limit -gt 0 -and $retrieved -eq $Limit) { + Write-Verbose "Limit reached: $Limit" + $overLimit = $true + } + elseif ($Limit -gt 0 -and ($retrieved + $PageSize) -gt $Limit) { + $newPS = $Limit - $retrieved + Write-Verbose ("Reducing PageSize from {0} to {1} to meet limit with next page" -f $PageSize,$newPS) + $request.MaxResults = $newPS + } + [int]$i = $i + $result.DataTransfers.Count + } + until ($overLimit -or !$result.NextPageToken) + return $response + } + } + catch { + if ($ErrorActionPreference -eq 'Stop') { + $PSCmdlet.ThrowTerminatingError($_) + } + else { + Write-Error $_ + } + } + } +} diff --git a/PSGSuite/Public/Drive/Start-GSDriveFileUpload.ps1 b/PSGSuite/Public/Drive/Start-GSDriveFileUpload.ps1 index b660718d..04bcb8a3 100644 --- a/PSGSuite/Public/Drive/Start-GSDriveFileUpload.ps1 +++ b/PSGSuite/Public/Drive/Start-GSDriveFileUpload.ps1 @@ -9,11 +9,6 @@ function Start-GSDriveFileUpload { .PARAMETER Path The path of the file or folder to upload - .PARAMETER Name - The new name of the file once uploaded - - Defaults to the existing name of the file or folder - .PARAMETER Description The description of the file or folder in Drive @@ -54,9 +49,6 @@ function Start-GSDriveFileUpload { $Path, [parameter(Mandatory = $false)] [String] - $Name, - [parameter(Mandatory = $false)] - [String] $Description, [parameter(Mandatory = $false)] [String[]] @@ -111,10 +103,14 @@ function Start-GSDriveFileUpload { Type = 'DriveFolder' Verbose = $false } + $parentVerbose = $null if ($PSBoundParameters.Keys -contains 'Parents') { $newFolPerms['Parents'] = $PSBoundParameters['Parents'] + if ($par = Get-GSDriveFileInfo -FileId $PSBoundParameters['Parents'] -User $User -Verbose:$false -ErrorAction Stop) { + $parentVerbose = " under parent folder '$($par.Name -join ',')'" + } } - Write-Verbose "Creating new Drive folder '$($details.Name)'" + Write-Verbose "Creating new Drive folder '$($details.Name)'$parentVerbose" $id = New-GSDriveFile @newFolPerms | Select-Object -ExpandProperty Id $folIdHash[$details.FullName.TrimEnd('\').TrimEnd('/')] = $id if ($Recurse) { diff --git a/PSGSuite/Public/Resources/Update-GSResource.ps1 b/PSGSuite/Public/Resources/Update-GSResource.ps1 index ad2bf1f0..fa029ee2 100644 --- a/PSGSuite/Public/Resources/Update-GSResource.ps1 +++ b/PSGSuite/Public/Resources/Update-GSResource.ps1 @@ -2,44 +2,41 @@ function Update-GSResource { <# .SYNOPSIS Updates a Calendar Resource - + .DESCRIPTION Updates a Calendar Resource - + .PARAMETER ResourceId The unique Id of the Resource Calendar that you would like to update - + .PARAMETER BuildingId If updating a Resource Building, the unique Id of the building you would like to update If updating a Resource Calendar, the new Building Id for the resource - + .PARAMETER FeatureKey The unique key of the Feature you would like to update - + .PARAMETER Name The new name of the resource - - .PARAMETER Id - The unique ID for the calendar resource. - + .PARAMETER Description Description of the resource, visible only to admins. - + .PARAMETER Capacity Capacity of a resource, number of seats in a room. - + .PARAMETER FloorName Name of the floor a resource is located on (Calendars Resource type) - + .PARAMETER FloorNames The names of the floors in the building (Buildings Resource type) - + .PARAMETER FloorSection Name of the section within a floor a resource is located in. - + .PARAMETER Category - The new category of the calendar resource. Either CONFERENCE_ROOM or OTHER. Legacy data is set to CATEGORY_UNKNOWN. + The new category of the calendar resource. Either CONFERENCE_ROOM or OTHER. Legacy data is set to CATEGORY_UNKNOWN. Acceptable values are: * "CATEGORY_UNKNOWN" @@ -47,31 +44,31 @@ function Update-GSResource { * "OTHER" Defaults to 'CATEGORY_UNKNOWN' if creating a Calendar Resource - + .PARAMETER ResourceType The type of the calendar resource, intended for non-room resources. - + .PARAMETER UserVisibleDescription Description of the resource, visible to users and admins. - + .PARAMETER Resource - The resource type you would like to create + The resource type you would like to update Available values are: * "Calendars": create a Resource Calendar or legacy resource type * "Buildings": create a Resource Building * "Features": create a Resource Feature - + .EXAMPLE - Update-GSResource -ResourceId Train01 -Id TrainingRoom01 + Update-GSResource -ResourceId Train01 -Name 'Corp Training Room' - Updates the resource Id 'Train01' to the new Id 'TrainingRoom01' + Updates the calendar resource with ID 'Train01' to the new name 'Corp Training Room' #> [CmdletBinding()] Param ( [parameter(Mandatory = $true,Position = 0,ValueFromPipelineByPropertyName = $true,ParameterSetName = 'Calendars')] - [Alias('CalendarResourceId')] + [Alias('CalendarResourceId','Id')] [String] $ResourceId, [parameter(Mandatory = $true,Position = 0,ValueFromPipelineByPropertyName = $true,ParameterSetName = 'Buildings')] @@ -85,9 +82,6 @@ function Update-GSResource { [String] $Name, [parameter(Mandatory = $false,ParameterSetName = 'Calendars')] - [String] - $Id, - [parameter(Mandatory = $false,ParameterSetName = 'Calendars')] [parameter(Mandatory = $false,ParameterSetName = 'Buildings')] [String] $Description, @@ -118,7 +112,7 @@ function Update-GSResource { [String] $Resource ) - Begin { + Process { $resType = if ($MyInvocation.InvocationName -eq 'Update-GSCalendarResource') { 'Calendars' } @@ -136,8 +130,6 @@ function Update-GSResource { if ($PSBoundParameters -notcontains 'Category' -and $PSCmdlet.ParameterSetName -eq 'Calendars') { $PSBoundParameters['Category'] = 'CATEGORY_UNKNOWN' } - } - Process { try { Write-Verbose "Creating Resource $resType '$Name'" $body = New-Object "$(switch ($resType) { @@ -156,15 +148,6 @@ function Update-GSResource { Category { $body.ResourceCategory = $PSBoundParameters[$key] } - Id { - if ($resType -eq 'Calendars') { - $body.ResourceId = $PSBoundParameters[$key] - } - else { - $body.$key = $PSBoundParameters[$key] - } - - } Name { if ($resType -eq 'Calendars') { $body.ResourceName = $PSBoundParameters[$key] @@ -219,4 +202,4 @@ function Update-GSResource { } } } -} \ No newline at end of file +} diff --git a/README.md b/README.md index b180c93a..1b9dd5ec 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,21 @@ All other functions are either intact or have an alias included to support backw [Full CHANGELOG here](https://github.com/scrthq/PSGSuite/blob/master/CHANGELOG.md) +#### 2.33.1 - 2019-10-06 + +* [Issue #235](https://github.com/scrthq/PSGSuite/issues/235) + * Removed: `Name` parameter from `Start-GSDriveFileUpload` as it was unused in the function and doesnt make sense when uploading an array of files. +* [Issue #238](https://github.com/scrthq/PSGSuite/issues/238) + * Added: `Get-GSDataTransfer` to Get/List current Data Transfers +* [Issue #239](https://github.com/scrthq/PSGSuite/issues/239) + * Removed: `Update-GSResource` `Id` parameter as it was non-applicable (duplicate of `ResourceId` and not writable per API docs) + * Cleaned up function help and examples to match changes +* [Issue #240](https://github.com/scrthq/PSGSuite/issues/240) + * Fixed: `Get-GSCalendar` now properly resolves single calendar metadata retrieval and passes List requests to `Get-GSCalendarSubscription` since the `Calendars` service does not support List requests. +* Miscellaneous + * Updated Google .NET SDKs to latest versions + * Cleaned up build.ps1 script + #### 2.33.0 - 2019-09-26 * [Issue #236](https://github.com/scrthq/PSGSuite/issues/236) diff --git a/build.ps1 b/build.ps1 index bbca8375..2376bca0 100644 --- a/build.ps1 +++ b/build.ps1 @@ -13,7 +13,14 @@ param( [switch]$Help ) $env:_BuildStart = Get-Date -Format 'o' - +$ModuleName = 'PSGSuite' +$Dependencies = @{ + Configuration = '1.3.1' + psake = '4.9.0' +} +if ($env:SYSTEM_STAGENAME -eq 'Build') { + $Dependencies['PowerShellGet'] = '2.2.1' +} $update = @{} $verbose = @{} if ($PSBoundParameters.ContainsKey('UpdateModules')) { @@ -35,7 +42,8 @@ if ($Help) { Format-Table -Property Name, Description, Alias, DependsOn } else { - $env:BuildProjectName = 'PSGSuite' + + $env:BuildProjectName = $ModuleName $env:BuildScriptPath = $PSScriptRoot if ($Task -contains 'Docs') { @@ -45,7 +53,7 @@ else { $env:NoNugetRestore = $NoRestore } - Invoke-CommandWithLog {$global:PSDefaultParameterValues = @{ + $global:PSDefaultParameterValues = @{ '*-Module:Verbose' = $false 'Import-Module:ErrorAction' = 'Stop' 'Import-Module:Force' = $true @@ -56,40 +64,45 @@ else { 'Install-Module:Scope' = 'CurrentUser' 'Install-Module:Repository' = 'PSGallery' 'Install-Module:Verbose' = $false - }} + } Get-PackageProvider -Name Nuget -ForceBootstrap -Verbose:$false Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Verbose:$false Add-EnvironmentSummary "Build started" - Set-BuildVariables - Add-Heading "Updating PackageManagement and PowerShellGet modules if needed" - $modHash = @{ - PackageManagement = '1.4.4' - PowerShellGet = '2.2.1' + Add-Heading "Pulling module and build dependencies" + [hashtable[]]$moduleDependencies = @() + foreach ($module in $Dependencies.Keys) { + $moduleDependencies += @{ + Name = $module + MinimumVersion = $Dependencies[$module] + } } - if ($env:SYSTEM_JOBDISPLAYNAME -eq 'Compile Module') { - Get-Module PackageManagement,PowerShellGet | Remove-Module -Force - foreach ($mod in $modHash.GetEnumerator()) { - try { - if ($null -eq (Get-Module $mod.Key -ListAvailable | Where-Object {[version]$_.Version -ge [version]$mod.Value})) { - Write-BuildLog "Updating module: $($mod.Key)" - Install-Module $mod.Key -Repository PSGallery -Force -AllowClobber -ErrorAction SilentlyContinue - } - else { - Write-BuildLog "$($mod.Key) is already >= $($mod.Value)! Skipping" - } + (Import-PowerShellDataFile ([System.IO.Path]::Combine($PSScriptRoot,$ModuleName,"$ModuleName.psd1"))).RequiredModules | ForEach-Object { + $item = $_ + if ($item -is [hashtable] -and $Dependencies.Keys -notcontains $item.ModuleName) { + Write-BuildLog "Adding new dependency from PSD1: $($item.ModuleName)" + $hash = @{ + Name = $item.ModuleName } - catch { - + if ($item.ContainsKey('ModuleVersion')) { + $hash['MinimumVersion'] = $item.ModuleVersion + } + $moduleDependencies += $hash + } + elseif ($item -is [string] -and $Dependencies.Keys -notcontains $item) { + $moduleDependencies += @{ + Name = $item } } } - - Get-Module PackageManagement,PowerShellGet | Remove-Module -Force - Import-Module PowerShellGet -Force - Get-Module PackageManagement,PowerShellGet | Format-Table Name,Version -AutoSize + try { + $null = Get-PackageProvider -Name Nuget -ForceBootstrap -Verbose:$false -ErrorAction Stop + } + catch { + throw + } Add-Heading "Finalizing build prerequisites" if ( @@ -133,8 +146,8 @@ else { Import-Module 'BuildHelpers' -RequiredVersion 2.0.1 #> Write-BuildLog "Resolving necessary modules" - 'psake' | Resolve-Module @update -Verbose - Write-BuildLog "Modules successfully resolved" + $moduleDependencies.Name | Resolve-Module -UpdateModules -Verbose + Write-BuildLog "Modules resolved" if ($Task -eq 'TestOnly') { $global:ExcludeTag = @('Module') }