diff --git a/CHANGELOG.md b/CHANGELOG.md index bf4b98d6..9e2f6b53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ * [PSGSuite - ChangeLog](#psgsuite---changelog) + * [2.32.0 - 2019-09-12](#2320---2019-09-12) * [2.31.1 - 2019-08-30](#2311---2019-08-30) * [2.31.0](#2310) * [2.30.2](#2302) @@ -96,6 +97,30 @@ # PSGSuite - ChangeLog +## 2.32.0 - 2019-09-12 + +* [Issue #229](https://github.com/scrthq/PSGSuite/issues/229) + * Added: `Update-GSGmailLanguageSettings` and `Get-GSGmailLanguageSettings` functions to update/get a users default language settings in Gmail. +* [Issue #231](https://github.com/scrthq/PSGSuite/issues/231) + * Added: `Update-GSCalenderSubscription` function to updated existing calendar subscriptions. + * Removed: Default values for the following parameters on `Add-GSCalendarSubscription` to prevent automatically adding notifications for new CalendarList entries (subscriptions): + * `DefaultNotificationType` + * `DefaultNotificationMethod` + * `DefaultReminderMethod` + * `DefaultReminderMinutes` + * Added: `Notifications` and `Reminders` parameters to `Add-GSCalenderSubscription` and `Update-GSCalenderSubscription` + * Added: `Reminders` parameter to `New-GSCalendarEvent` and `Update-GSCalendarEvent` functions to set custom reminders on calendar events. + * Added: `Add-GSCalendarEventReminder` and `Add-GSCalendarNotification` helper functions. + * Updated: `DisableReminder` switch parameter name on `New-GSCalendarEvent` and `Update-GSCalendarEvent` functions to `DisableDefaultReminder` to better align with what that actually effects (default reminder inheritance only, not reminder overrides). The previous parameter name has been set as an alias to maintain backwards compatibility. + * Added: `RemoveAllReminders` parameter to `Update-GSCalendarEvent` to remove all custom reminders and disable calendar inheritance. +* [Issue #232](https://github.com/scrthq/PSGSuite/issues/232) + * Added: `Visibility` parameter on `New-GSCalendarEvent` and `Update-GSCalendarEvent` to set the visibility of a calendar event. +* Miscellaneous + * Forced `Type` parameter values to lower on the `Add-GSUser*` helper functions to ensure case senstive field matches whats expected. + * Updated Google .NET SDKs to latest versions. + * Updated and corrected a LOT of comment based function help. + * Added function help tests to validate that functions contain expected help content. + ## 2.31.1 - 2019-08-30 * [Issue #222](https://github.com/scrthq/PSGSuite/issues/222) diff --git a/PSGSuite/PSGSuite.psd1 b/PSGSuite/PSGSuite.psd1 index 74b005c8..20ae5cd9 100644 --- a/PSGSuite/PSGSuite.psd1 +++ b/PSGSuite/PSGSuite.psd1 @@ -12,7 +12,7 @@ RootModule = 'PSGSuite.psm1' # Version number of this module. - ModuleVersion = '2.31.1' + ModuleVersion = '2.32.0' # ID used to uniquely identify this module GUID = '9d751152-e83e-40bb-a6db-4c329092aaec' diff --git a/PSGSuite/Public/Authentication/Get-GSToken.ps1 b/PSGSuite/Public/Authentication/Get-GSToken.ps1 index 97237da3..e22ad5cf 100644 --- a/PSGSuite/Public/Authentication/Get-GSToken.ps1 +++ b/PSGSuite/Public/Authentication/Get-GSToken.ps1 @@ -1,11 +1,17 @@ function Get-GSToken { <# - .Synopsis + .SYNOPSIS Requests an Access Token for REST API authentication. Defaults to 3600 seconds token expiration time. .DESCRIPTION Requests an Access Token for REST API authentication. Defaults to 3600 seconds token expiration time. + .PARAMETER Scopes + The list of scopes to request the token for + + .PARAMETER AdminEmail + The email address of the user to request the token for. This is typically the Admin user. + .EXAMPLE $Token = Get-GSToken -Scopes 'https://www.google.com/m8/feeds' -AdminEmail $User $headers = @{ @@ -13,8 +19,7 @@ function Get-GSToken { 'GData-Version' = '3.0' } #> - Param - ( + Param ( [parameter(Mandatory = $true)] [Alias('Scope')] [ValidateNotNullOrEmpty()] diff --git a/PSGSuite/Public/Authentication/New-GoogleService.ps1 b/PSGSuite/Public/Authentication/New-GoogleService.ps1 index b5cb95a3..ad3f30d4 100644 --- a/PSGSuite/Public/Authentication/New-GoogleService.ps1 +++ b/PSGSuite/Public/Authentication/New-GoogleService.ps1 @@ -1,4 +1,27 @@ function New-GoogleService { + <# + .SYNOPSIS + Creates a new Google Service object that handles authentication for the scopes specified + + .DESCRIPTION + Creates a new Google Service object that handles authentication for the scopes specified + + .PARAMETER Scope + The scope or scopes to build the service with, e.g. https://www.googleapis.com/auth/admin.reports.audit.readonly + + .PARAMETER ServiceType + The type of service to create, e.g. Google.Apis.Admin.Reports.reports_v1.ReportsService + + .PARAMETER User + The user to request the service for during the authentication process + + .EXAMPLE + $serviceParams = @{ + Scope = 'https://www.googleapis.com/auth/admin.reports.audit.readonly' + ServiceType = 'Google.Apis.Admin.Reports.reports_v1.ReportsService' + } + $service = New-GoogleService @serviceParams + #> [CmdletBinding()] Param( [Parameter(Mandatory = $true,Position = 0)] diff --git a/PSGSuite/Public/Calendar/Add-GSCalendarSubscription.ps1 b/PSGSuite/Public/Calendar/Add-GSCalendarSubscription.ps1 index b3c3e880..0066c523 100644 --- a/PSGSuite/Public/Calendar/Add-GSCalendarSubscription.ps1 +++ b/PSGSuite/Public/Calendar/Add-GSCalendarSubscription.ps1 @@ -12,12 +12,20 @@ function Add-GSCalendarSubscription { .PARAMETER CalendarID The calendar ID of the calendar you would like to subscribe the user to + .PARAMETER ColorRgbFormat + Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. + .PARAMETER Selected Whether the calendar content shows up in the calendar UI. Optional. The default is False. .PARAMETER Hidden Whether the calendar has been hidden from the list. Optional. The default is False. + .PARAMETER Reminders + A list of reminders to add to this calendar. + + This parameter expects a 'Google.Apis.Calendar.v3.Data.EventReminder[]' object type. You can create objects of this type easily by using the function 'Add-GSCalendarEventReminder' + .PARAMETER DefaultReminderMethod The method used by this reminder. Defaults to email. @@ -31,15 +39,20 @@ function Add-GSCalendarSubscription { Valid values are between 0 and 40320 (4 weeks in minutes). + .PARAMETER Notifications + A list of notifications to add to this calendar. + + This parameter expects a 'Google.Apis.Calendar.v3.Data.CalendarNotification[]' object type. You can create objects of this type easily by using the function 'Add-GSCalendarNotification' + .PARAMETER DefaultNotificationMethod - The method used to deliver the notification. Defaults to email. + The method used to deliver the notification. Possible values are: * "email" - Reminders are sent via email. * "sms" - Reminders are sent via SMS. This value is read-only and is ignored on inserts and updates. SMS reminders are only available for G Suite customers. .PARAMETER DefaultNotificationType - The type of notification. Defaults to eventChange. + The type of notification. Possible values are: * "eventCreation" - Notification sent when a new event is put on the calendar. @@ -63,41 +76,50 @@ function Add-GSCalendarSubscription { [cmdletbinding()] Param ( - [parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)] + [parameter(Mandatory,Position = 0,ValueFromPipeline,ValueFromPipelineByPropertyName)] [Alias("PrimaryEmail","UserKey","Mail")] [ValidateNotNullOrEmpty()] [String] $User, - [parameter(Mandatory = $true)] + [parameter(Mandatory,Position = 1)] [String[]] $CalendarId, [parameter(Mandatory = $false)] [Switch] + $ColorRgbFormat, + [parameter()] + [Switch] $Selected, - [parameter(Mandatory = $false)] + [parameter()] [Switch] $Hidden, - [parameter(Mandatory = $false)] + [parameter()] + [Google.Apis.Calendar.v3.Data.EventReminder[]] + $Reminders, + [parameter()] [ValidateSet('email','sms','popup')] [String] - $DefaultReminderMethod = 'email', - [parameter(Mandatory = $false)] + $DefaultReminderMethod, + [parameter()] [ValidateRange(0,40320)] [Int] $DefaultReminderMinutes = 30, - [parameter(Mandatory = $false)] + [parameter()] + [Google.Apis.Calendar.v3.Data.CalendarNotification[]] + $Notifications, + [parameter()] [ValidateSet('email','sms')] [String] - $DefaultNotificationMethod = 'email', - [parameter(Mandatory = $false)] + $DefaultNotificationMethod, + [parameter()] [ValidateSet('eventCreation','eventChange','eventCancellation','eventResponse','agenda')] [String] - $DefaultNotificationType = 'eventChange', - [parameter(Mandatory = $false)] + $DefaultNotificationType, + [parameter()] [ValidateSet("Periwinkle","Seafoam","Lavender","Coral","Goldenrod","Beige","Cyan","Grey","Blue","Green","Red")] [String] $Color, - [parameter(Mandatory = $false)] + [parameter()] [String] $SummaryOverride ) @@ -136,16 +158,32 @@ function Add-GSCalendarSubscription { Selected = $Selected Hidden = $Hidden } - $DefaultReminders = New-Object 'Google.Apis.Calendar.v3.Data.EventReminder' -Property @{ - Method = $DefaultReminderMethod - Minutes = $DefaultReminderMinutes + if ($PSBoundParameters.ContainsKey('Reminders')) { + $body.DefaultReminders = $Reminders + } + elseif ($PSBoundParameters.ContainsKey('DefaultReminderMethod')) { + $DefaultReminders = New-Object 'Google.Apis.Calendar.v3.Data.EventReminder' -Property @{ + Method = $DefaultReminderMethod + Minutes = $DefaultReminderMinutes + } + $body.DefaultReminders = [Google.Apis.Calendar.v3.Data.EventReminder[]]$DefaultReminders + } + if ($PSBoundParameters.ContainsKey('Notifications')) { + $body.NotificationSettings = New-Object 'Google.Apis.Calendar.v3.Data.CalendarListEntry+NotificationSettingsData' -Property @{ + Notifications = [Google.Apis.Calendar.v3.Data.CalendarNotification[]]$Notifications + } } - $body.DefaultReminders = [Google.Apis.Calendar.v3.Data.EventReminder[]]$DefaultReminders - $DefaultNotification = New-Object 'Google.Apis.Calendar.v3.Data.CalendarNotification' - $DefaultNotification.Method = $DefaultNotificationMethod - $DefaultNotification.Type = $DefaultNotificationType - $body.NotificationSettings = New-Object 'Google.Apis.Calendar.v3.Data.CalendarListEntry+NotificationSettingsData' -Property @{ - Notifications = [Google.Apis.Calendar.v3.Data.CalendarNotification[]]$DefaultNotification + elseif ($PSBoundParameters.ContainsKey('DefaultNotificationMethod') -or $PSBoundParameters.ContainsKey('DefaultNotificationType')) { + $DefaultNotification = New-Object 'Google.Apis.Calendar.v3.Data.CalendarNotification' + if ($PSBoundParameters.ContainsKey('DefaultNotificationMethod')) { + $DefaultNotification.Method = $DefaultNotificationMethod + } + if ($PSBoundParameters.ContainsKey('DefaultNotificationType')) { + $DefaultNotification.Type = $DefaultNotificationType + } + $body.NotificationSettings = New-Object 'Google.Apis.Calendar.v3.Data.CalendarListEntry+NotificationSettingsData' -Property @{ + Notifications = [Google.Apis.Calendar.v3.Data.CalendarNotification[]]$DefaultNotification + } } foreach ($key in $PSBoundParameters.Keys) { switch ($key) { @@ -161,6 +199,9 @@ function Add-GSCalendarSubscription { } Write-Verbose "Subscribing user '$User' to Calendar '$($calId)'" $request = $service.CalendarList.Insert($body) + if ($PSBoundParameters.ContainsKey('ColorRgbFormat')) { + $request.ColorRgbFormat = $ColorRgbFormat + } $request.Execute() } } diff --git a/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 b/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 index 96b2af59..4bea7063 100644 --- a/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 +++ b/PSGSuite/Public/Calendar/Get-GSCalendar.ps1 @@ -39,6 +39,11 @@ function Get-GSCalendar { 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-GSCalendar + + Gets the list of calendar subscriptions for the AdminEmail user. #> [OutputType('Google.Apis.Calendar.v3.Data.CalendarListEntry')] [cmdletbinding(DefaultParameterSetName = "List")] diff --git a/PSGSuite/Public/Calendar/Get-GSCalendarEvent.ps1 b/PSGSuite/Public/Calendar/Get-GSCalendarEvent.ps1 index 331e35df..06666859 100644 --- a/PSGSuite/Public/Calendar/Get-GSCalendarEvent.ps1 +++ b/PSGSuite/Public/Calendar/Get-GSCalendarEvent.ps1 @@ -6,16 +6,19 @@ function Get-GSCalendarEvent { .DESCRIPTION Gets the calendar events for a user - .PARAMETER User - The primary email or UserID of the user. 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. - - Defaults to the AdminEmail in the config + .PARAMETER EventId + The Id of the event to get info for .PARAMETER CalendarId The calendar ID of the calendar you would like to list events from. Defaults to the user's primary calendar + .PARAMETER User + The primary email or UserID of the user. 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. + + Defaults to the AdminEmail in the config + .PARAMETER Filter Free text search terms to find events that match these terms in any field, except for extended properties. @@ -44,6 +47,12 @@ function Get-GSCalendarEvent { .PARAMETER SingleEvents Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. + .PARAMETER PrivateExtendedProperty + Extended properties constraint specified as a hashtable where propertyName=value. Matches only private properties. + + .PARAMETER SharedExtendedProperty + Extended properties constraint specified as a hashtable where propertyName=value. Matches only shared properties. + .PARAMETER TimeMin Lower bound (inclusive) for an event's end time to filter by. If TimeMax is set, TimeMin must be smaller than timeMax. diff --git a/PSGSuite/Public/Calendar/New-GSCalendarEvent.ps1 b/PSGSuite/Public/Calendar/New-GSCalendarEvent.ps1 index 8e014669..3de88310 100644 --- a/PSGSuite/Public/Calendar/New-GSCalendarEvent.ps1 +++ b/PSGSuite/Public/Calendar/New-GSCalendarEvent.ps1 @@ -47,7 +47,12 @@ function New-GSCalendarEvent { .PARAMETER EventColor Color of the event as seen in Calendar - .PARAMETER DisableReminder + .PARAMETER Reminders + A list of reminders to add to this calendar event other than the default calendar reminder. + + This parameter expects a 'Google.Apis.Calendar.v3.Data.EventReminder[]' object type. You can create objects of this type easily by using the function 'Add-GSCalendarEventReminder' + + .PARAMETER DisableDefaultReminder When $true, disables inheritance of the default Reminders from the Calendar the event was created on. .PARAMETER LocalStartDateTime @@ -124,9 +129,13 @@ function New-GSCalendarEvent { [ValidateSet("Periwinkle","Seafoam","Lavender","Coral","Goldenrod","Beige","Cyan","Grey","Blue","Green","Red")] [String] $EventColor, + [parameter()] + [Google.Apis.Calendar.v3.Data.EventReminder[]] + $Reminders, [parameter(Mandatory = $false)] + [Alias('DisableReminder')] [Switch] - $DisableReminder, + $DisableDefaultReminder, [parameter(Mandatory = $false)] [DateTime] $LocalStartDateTime = (Get-Date), @@ -194,6 +203,7 @@ function New-GSCalendarEvent { if ($Attendees) { $body.Attendees = [Google.Apis.Calendar.v3.Data.EventAttendee[]]$Attendees } + $RemindersData = $null foreach ($key in $PSBoundParameters.Keys) { switch ($key) { EventColor { @@ -227,11 +237,17 @@ function New-GSCalendarEvent { $ExtendedProperties.Shared.Add($prop,$SharedExtendedProperties[$prop]) } } - DisableReminder { - $reminder = New-Object 'Google.Apis.Calendar.v3.Data.Event+RemindersData' -Property @{ - UseDefault = (-not $DisableReminder) + Reminders { + if ($null -eq $RemindersData) { + $RemindersData = New-Object 'Google.Apis.Calendar.v3.Data.Event+RemindersData' } - $body.Reminders = $reminder + $RemindersData.Overrides = $Reminders + } + DisableDefaultReminder { + if ($null -eq $RemindersData) { + $RemindersData = New-Object 'Google.Apis.Calendar.v3.Data.Event+RemindersData' + } + $RemindersData.UseDefault = (-not $DisableDefaultReminder) } Default { if ($body.PSObject.Properties.Name -contains $key) { @@ -240,6 +256,9 @@ function New-GSCalendarEvent { } } } + if ($RemindersData) { + $body.Reminders = $RemindersData + } if ($ExtendedProperties) { $body.ExtendedProperties = $ExtendedProperties } diff --git a/PSGSuite/Public/Calendar/Update-GSCalendarEvent.ps1 b/PSGSuite/Public/Calendar/Update-GSCalendarEvent.ps1 index 63272286..151d8c84 100644 --- a/PSGSuite/Public/Calendar/Update-GSCalendarEvent.ps1 +++ b/PSGSuite/Public/Calendar/Update-GSCalendarEvent.ps1 @@ -36,10 +36,27 @@ function Update-GSCalendarEvent { .PARAMETER Location Event location + .PARAMETER Visibility + Visibility of the event. + + Possible values are: + * "default" - Uses the default visibility for events on the calendar. This is the default value. + * "public" - The event is public and event details are visible to all readers of the calendar. + * "private" - The event is private and only event attendees may view event details. + * "confidential" - The event is private. This value is provided for compatibility reasons. + .PARAMETER EventColor Color of the event as seen in Calendar - .PARAMETER DisableReminder + .PARAMETER Reminders + A list of reminders to add to this calendar event. + + This parameter expects a 'Google.Apis.Calendar.v3.Data.EventReminder[]' object type. You can create objects of this type easily by using the function 'Add-GSCalendarEventReminder' + + .PARAMETER RemoveAllReminders + If $true, removes all reminder overrides and disables the default reminder inheritance from the calendar that the event is on. + + .PARAMETER DisableDefaultReminder When $true, disables inheritance of the default Reminders from the Calendar the event was created on. .PARAMETER LocalStartDateTime @@ -112,12 +129,23 @@ function Update-GSCalendarEvent { [String] $Location, [parameter(Mandatory = $false)] + [ValidateSet('default','public','private','confidential')] + [String] + $Visibility, + [parameter(Mandatory = $false)] [ValidateSet("Periwinkle","Seafoam","Lavender","Coral","Goldenrod","Beige","Cyan","Grey","Blue","Green","Red")] [String] $EventColor, + [parameter()] + [Google.Apis.Calendar.v3.Data.EventReminder[]] + $Reminders, [parameter(Mandatory = $false)] [Switch] - $DisableReminder, + $RemoveAllReminders, + [parameter(Mandatory = $false)] + [Alias('DisableReminder')] + [Switch] + $DisableDefaultReminder, [parameter(Mandatory = $false)] [DateTime] $LocalStartDateTime, @@ -185,6 +213,7 @@ function Update-GSCalendarEvent { if ($Attendees) { $body.Attendees = [Google.Apis.Calendar.v3.Data.EventAttendee[]]$Attendees } + $RemindersData = $null foreach ($key in $PSBoundParameters.Keys) { switch ($key) { EventColor { @@ -218,11 +247,23 @@ function Update-GSCalendarEvent { $ExtendedProperties.Shared.Add($prop,$SharedExtendedProperties[$prop]) } } - DisableReminder { - $reminder = New-Object 'Google.Apis.Calendar.v3.Data.Event+RemindersData' -Property @{ - UseDefault = (-not $DisableReminder) + Reminders { + if ($null -eq $RemindersData) { + $RemindersData = New-Object 'Google.Apis.Calendar.v3.Data.Event+RemindersData' + } + $RemindersData.Overrides = $Reminders + } + RemoveAllReminders { + $RemindersData = New-Object 'Google.Apis.Calendar.v3.Data.Event+RemindersData' -Property @{ + UseDefault = $false + Overrides = New-Object 'System.Collections.Generic.List[Google.Apis.Calendar.v3.Data.EventReminder]' } - $body.Reminders = $reminder + } + DisableDefaultReminder { + if ($null -eq $RemindersData) { + $RemindersData = New-Object 'Google.Apis.Calendar.v3.Data.Event+RemindersData' + } + $RemindersData.UseDefault = (-not $DisableDefaultReminder) } Default { if ($body.PSObject.Properties.Name -contains $key) { @@ -231,6 +272,9 @@ function Update-GSCalendarEvent { } } } + if ($RemindersData) { + $body.Reminders = $RemindersData + } if ($ExtendedProperties) { $body.ExtendedProperties = $ExtendedProperties } diff --git a/PSGSuite/Public/Calendar/Update-GSCalendarSubscription.ps1 b/PSGSuite/Public/Calendar/Update-GSCalendarSubscription.ps1 new file mode 100644 index 00000000..c3113e20 --- /dev/null +++ b/PSGSuite/Public/Calendar/Update-GSCalendarSubscription.ps1 @@ -0,0 +1,259 @@ +function Update-GSCalendarSubscription { + <# + .SYNOPSIS + Updates a calendar in a users calendar list (aka subscription) + + .DESCRIPTION + Updates a calendar in a users calendar list (aka subscription) + + .PARAMETER User + The primary email or UserID of the user. 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. + + .PARAMETER CalendarID + The calendar ID of the calendar subscription you would like to update. + + .PARAMETER ColorRgbFormat + Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. + + .PARAMETER Selected + Whether the calendar content shows up in the calendar UI. Optional. The default is False. + + .PARAMETER Hidden + Whether the calendar has been hidden from the list. Optional. The default is False. + + .PARAMETER Reminders + A list of reminders to add to this calendar. + + This parameter expects a 'Google.Apis.Calendar.v3.Data.EventReminder[]' object type. You can create objects of this type easily by using the function 'Add-GSCalendarEventReminder' + + .PARAMETER RemoveReminders + If $true, removes reminders from this CalendarSubscription. + + .PARAMETER DefaultReminderMethod + The method used by this reminder. Defaults to email. + + Possible values are: + * "email" - Reminders are sent via email. + * "sms" - Reminders are sent via SMS. These are only available for G Suite customers. Requests to set SMS reminders for other account types are ignored. + * "popup" - Reminders are sent via a UI popup. + + .PARAMETER DefaultReminderMinutes + Number of minutes before the start of the event when the reminder should trigger. Defaults to 30 minutes. + + Valid values are between 0 and 40320 (4 weeks in minutes). + + .PARAMETER Notifications + A list of notifications to add to this calendar. + + This parameter expects a 'Google.Apis.Calendar.v3.Data.CalendarNotification[]' object type. You can create objects of this type easily by using the function 'Add-GSCalendarNotification' + + .PARAMETER RemoveNotifications + If $true, removes notifications from this CalendarSubscription. + + .PARAMETER DefaultNotificationMethod + The method used to deliver the notification. + + Possible values are: + * "email" - Reminders are sent via email. + * "sms" - Reminders are sent via SMS. This value is read-only and is ignored on inserts and updates. SMS reminders are only available for G Suite customers. + + .PARAMETER DefaultNotificationType + The type of notification. + + Possible values are: + * "eventCreation" - Notification sent when a new event is put on the calendar. + * "eventChange" - Notification sent when an event is changed. + * "eventCancellation" - Notification sent when an event is cancelled. + * "eventResponse" - Notification sent when an event is changed. + * "agenda" - An agenda with the events of the day (sent out in the morning). + + .PARAMETER Color + The color of the calendar. + + .PARAMETER SummaryOverride + The summary that the authenticated user has set for this calendar. + + .EXAMPLE + Update-GSCalendarSubscription -User me -CalendarId john.smith@domain.com -Selected -Color Cyan + + Updates the calendar 'john.smith@domain.com' on the AdminEmail user's calendar list by marking it as selected and setting the color to Cyan + #> + [OutputType('Google.Apis.Calendar.v3.Data.CalendarListEntry')] + [cmdletbinding()] + Param + ( + [parameter(Mandatory,Position = 0,ValueFromPipeline,ValueFromPipelineByPropertyName)] + [Alias("PrimaryEmail","UserKey","Mail")] + [ValidateNotNullOrEmpty()] + [String] + $User, + [parameter(Mandatory,Position = 1,ValueFromPipelineByPropertyName)] + [Alias('Id')] + [String[]] + $CalendarId, + [parameter(Mandatory = $false)] + [Switch] + $ColorRgbFormat, + [parameter(Mandatory = $false)] + [Switch] + $Selected, + [parameter(Mandatory = $false)] + [Switch] + $Hidden, + [parameter()] + [Google.Apis.Calendar.v3.Data.EventReminder[]] + $Reminders, + [parameter()] + [switch] + $RemoveReminders, + [parameter(Mandatory = $false)] + [ValidateSet('email','sms','popup')] + [String] + $DefaultReminderMethod, + [parameter(Mandatory = $false)] + [ValidateRange(0,40320)] + [Int] + $DefaultReminderMinutes = 10, + [parameter()] + [Google.Apis.Calendar.v3.Data.CalendarNotification[]] + $Notifications, + [parameter()] + [switch] + $RemoveNotifications, + [parameter(Mandatory = $false)] + [ValidateSet('email','sms')] + [String] + $DefaultNotificationMethod, + [parameter(Mandatory = $false)] + [ValidateSet('eventCreation','eventChange','eventCancellation','eventResponse','agenda')] + [String] + $DefaultNotificationType, + [parameter(Mandatory = $false)] + [ValidateSet("Periwinkle","Seafoam","Lavender","Coral","Goldenrod","Beige","Cyan","Grey","Blue","Green","Red")] + [String] + $Color, + [parameter(Mandatory = $false)] + [String] + $SummaryOverride + ) + Begin { + $colorHash = @{ + Periwinkle = 1 + Seafoam = 2 + Lavender = 3 + Coral = 4 + Goldenrod = 5 + Beige = 6 + Cyan = 7 + Grey = 8 + Blue = 9 + Green = 10 + Red = 11 + } + } + Process { + try { + 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 + foreach ($calId in $CalendarID) { + $body = Get-GSCalendarSubscription -User $User -CalendarId $calId -Verbose:$false + if ($RemoveReminders) { + $body.DefaultReminders = New-Object 'System.Collections.Generic.List[Google.Apis.Calendar.v3.Data.EventReminder]' + } + elseif ($PSBoundParameters.ContainsKey('Reminders')) { + if ($null -eq $body.DefaultReminders) { + $body.DefaultReminders = $Reminders + } + else { + $Reminders | ForEach-Object { + $body.DefaultReminders.Add($_) | Out-Null + } + } + } + elseif ($PSBoundParameters.ContainsKey('DefaultReminderMethod')) { + $defReminder = New-Object 'Google.Apis.Calendar.v3.Data.EventReminder' -Property @{ + Method = $DefaultReminderMethod + Minutes = $DefaultReminderMinutes + } + if ($null -eq $body.DefaultReminders) { + $body.DefaultReminders = [Google.Apis.Calendar.v3.Data.EventReminder[]]$defReminder + } + else { + $body.DefaultReminders.Add($defReminder) + } + } + if ($RemoveNotifications) { + $body.NotificationSettings = New-Object 'Google.Apis.Calendar.v3.Data.CalendarListEntry+NotificationSettingsData' -Property @{ + Notifications = New-Object 'System.Collections.Generic.List[Google.Apis.Calendar.v3.Data.CalendarNotification]' + } + } + elseif ($PSBoundParameters.ContainsKey('Notifications')) { + if ($null -eq $body.NotificationSettings) { + $body.NotificationSettings = New-Object 'Google.Apis.Calendar.v3.Data.CalendarListEntry+NotificationSettingsData' -Property @{ + Notifications = [Google.Apis.Calendar.v3.Data.CalendarNotification[]]$Notifications + } + } + else { + $Notifications | ForEach-Object { + $body.NotificationSettings.Notifications.Add($_) | Out-Null + } + } + } + elseif ($PSBoundParameters.ContainsKey('DefaultNotificationMethod') -and $PSBoundParameters.ContainsKey('DefaultNotificationType')) { + if ($null -eq $body.NotificationSettings) { + $DefaultNotification = New-Object 'Google.Apis.Calendar.v3.Data.CalendarNotification' -Property @{ + Method = $DefaultNotificationMethod + Type = $DefaultNotificationType + } + $body.NotificationSettings = New-Object 'Google.Apis.Calendar.v3.Data.CalendarListEntry+NotificationSettingsData' -Property @{ + Notifications = [Google.Apis.Calendar.v3.Data.CalendarNotification[]]$DefaultNotification + } + } + else { + $DefaultNotification = New-Object 'Google.Apis.Calendar.v3.Data.CalendarNotification' -Property @{ + Method = $DefaultNotificationMethod + Type = $DefaultNotificationType + } + $body.NotificationSettings.Notifications.Add($DefaultNotification) | Out-Null + } + } + foreach ($key in $PSBoundParameters.Keys) { + switch ($key) { + Color { + $body.ColorId = $colorHash[$Color] + } + Default { + if ($body.PSObject.Properties.Name -contains $key) { + $body.$key = $PSBoundParameters[$key] + } + } + } + } + Write-Verbose "Updating Calendar '$($calId) for user '$User'" + $request = $service.CalendarList.Patch($body,$calId) + if ($PSBoundParameters.ContainsKey('ColorRgbFormat')) { + $request.ColorRgbFormat = $ColorRgbFormat + } + $request.Execute() + } + } + catch { + if ($ErrorActionPreference -eq 'Stop') { + $PSCmdlet.ThrowTerminatingError($_) + } + else { + Write-Error $_ + } + } + } +} diff --git a/PSGSuite/Public/Chat/Send-GSChatMessage.ps1 b/PSGSuite/Public/Chat/Send-GSChatMessage.ps1 index 4c4eb345..6d11f1d1 100644 --- a/PSGSuite/Public/Chat/Send-GSChatMessage.ps1 +++ b/PSGSuite/Public/Chat/Send-GSChatMessage.ps1 @@ -43,6 +43,11 @@ function Send-GSChatMessage { .PARAMETER ThreadKey Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. + .PARAMETER RestParent + The resource name of the space to send the message to via REST API call, in the form "spaces". + + Example: spaces/AAAAMpdlehY + .PARAMETER Webhook The Url of the Webhook for the space to send the message to. @@ -57,6 +62,9 @@ function Send-GSChatMessage { If section widgets are passed directly to this function, a new section without a SectionHeader will be created and the widgets will be added to it + .PARAMETER BodyPassThru + If $true, returns the message body. + .EXAMPLE Send-GSChatMessage -Text "Post job report:" -Cards $cards -Webhook (Get-GSChatWebhook JobReports) diff --git a/PSGSuite/Public/Chat/Update-GSChatMessage.ps1 b/PSGSuite/Public/Chat/Update-GSChatMessage.ps1 index d8fb1392..8422d3a5 100644 --- a/PSGSuite/Public/Chat/Update-GSChatMessage.ps1 +++ b/PSGSuite/Public/Chat/Update-GSChatMessage.ps1 @@ -45,6 +45,12 @@ function Update-GSChatMessage { If section widgets are passed directly to this function, a new section without a SectionHeader will be created and the widgets will be added to it + .PARAMETER BodyPassThru + If $true, returns the message body. + + .PARAMETER UseRest + If $true, uses the REST API. + .EXAMPLE Send-GSChatMessage -Text "Post job report:" -Cards $cards -Webhook (Get-GSChatWebhook JobReports) diff --git a/PSGSuite/Public/Classroom/Get-GSStudentGuardianInvitation.ps1 b/PSGSuite/Public/Classroom/Get-GSStudentGuardianInvitation.ps1 index e6840677..3292bac6 100644 --- a/PSGSuite/Public/Classroom/Get-GSStudentGuardianInvitation.ps1 +++ b/PSGSuite/Public/Classroom/Get-GSStudentGuardianInvitation.ps1 @@ -21,7 +21,7 @@ function Get-GSStudentGuardianInvitation { .PARAMETER GuardianEmail If specified, only results with the specified GuardianEmail will be returned. - .PARAMETER State + .PARAMETER States If specified, only results with the specified state values will be returned. Otherwise, results with a state of PENDING will be returned. The State can be one of the following: diff --git a/PSGSuite/Public/Configuration/Get-PSGSuiteConfig.ps1 b/PSGSuite/Public/Configuration/Get-PSGSuiteConfig.ps1 index 24ebd386..b6200290 100644 --- a/PSGSuite/Public/Configuration/Get-PSGSuiteConfig.ps1 +++ b/PSGSuite/Public/Configuration/Get-PSGSuiteConfig.ps1 @@ -20,6 +20,9 @@ function Get-PSGSuiteConfig { .PARAMETER PassThru If specified, returns the config after loading it + .PARAMETER NoImport + If $true, just returns the specified config but does not impart it in the current session. + .EXAMPLE Get-PSGSuiteConfig personalDomain -PassThru diff --git a/PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1 b/PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1 index 357d1446..e431e3ca 100644 --- a/PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1 +++ b/PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1 @@ -46,7 +46,10 @@ function Set-PSGSuiteConfig { The Service Account's Client ID from the Google Developer's Console. This is optional and is only used as a reference for yourself to prevent needing to check the Developer's Console for the ID when verifying API Client Access. .PARAMETER Webhook - Web + Chat Webhooks to add to the config. + + .PARAMETER Space + Chat spaces to add to the config. .PARAMETER Scope The scope at which you would like to set this config. diff --git a/PSGSuite/Public/Domains/Remove-GSDomainAlias.ps1 b/PSGSuite/Public/Domains/Remove-GSDomainAlias.ps1 index 6274aee3..fda730f1 100644 --- a/PSGSuite/Public/Domains/Remove-GSDomainAlias.ps1 +++ b/PSGSuite/Public/Domains/Remove-GSDomainAlias.ps1 @@ -6,8 +6,8 @@ function Remove-GSDomainAlias { .DESCRIPTION Removes a Domain Alias - .PARAMETER DomainName - Name of the domain to remove. + .PARAMETER DomainAliasName + Alias of the domain to remove. .EXAMPLE Remove-GSDDomainAlias 'testingalias.com' diff --git a/PSGSuite/Public/Drive/Export-GSDriveFile.ps1 b/PSGSuite/Public/Drive/Export-GSDriveFile.ps1 index ce5fd13e..d5c91340 100644 --- a/PSGSuite/Public/Drive/Export-GSDriveFile.ps1 +++ b/PSGSuite/Public/Drive/Export-GSDriveFile.ps1 @@ -50,6 +50,9 @@ function Export-GSDriveFile { .PARAMETER Fields The specific fields to returned + .PARAMETER Force + If $true, overwrites any existing files at the same path. + .EXAMPLE Export-GSDriveFile -FileId '1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976' -Type CSV -OutFilePath .\SheetExport.csv diff --git a/PSGSuite/Public/Drive/Get-GSDocContent.ps1 b/PSGSuite/Public/Drive/Get-GSDocContent.ps1 index 6455e778..ead5eaf0 100644 --- a/PSGSuite/Public/Drive/Get-GSDocContent.ps1 +++ b/PSGSuite/Public/Drive/Get-GSDocContent.ps1 @@ -2,18 +2,21 @@ function Get-GSDocContent { <# .SYNOPSIS Gets the content of a Google Doc and returns it as an array of strings. Supports HTML or PlainText - + .DESCRIPTION Gets the content of a Google Doc and returns it as an array of strings. Supports HTML or PlainText - + .PARAMETER FileID The unique Id of the file to get content of - + .PARAMETER User The email or unique Id of the owner of the Drive file Defaults to the AdminEmail user - + + .PARAMETER Type + Whether to get the results in HTML or PlainText format. + .EXAMPLE Get-GSDocContent -FileId '1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976' @@ -21,7 +24,7 @@ function Get-GSDocContent { #> [CmdLetBinding()] Param - ( + ( [parameter(Mandatory = $true,Position = 0)] [String] $FileID, @@ -54,4 +57,4 @@ function Get-GSDocContent { } } } -} \ No newline at end of file +} diff --git a/PSGSuite/Public/Drive/Get-GSDriveFile.ps1 b/PSGSuite/Public/Drive/Get-GSDriveFile.ps1 index a524b632..f18297b6 100644 --- a/PSGSuite/Public/Drive/Get-GSDriveFile.ps1 +++ b/PSGSuite/Public/Drive/Get-GSDriveFile.ps1 @@ -28,6 +28,9 @@ function Get-GSDriveFile { .PARAMETER Fields The specific fields to returned + .PARAMETER Force + If $true and OutFilePath is specified, overwrites any existing files at the desired path. + .EXAMPLE Get-GSDriveFile -FileId '1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976' diff --git a/PSGSuite/Public/Drive/Get-GSDriveProfile.ps1 b/PSGSuite/Public/Drive/Get-GSDriveProfile.ps1 index 21e58d0a..ebe6300a 100644 --- a/PSGSuite/Public/Drive/Get-GSDriveProfile.ps1 +++ b/PSGSuite/Public/Drive/Get-GSDriveProfile.ps1 @@ -11,6 +11,9 @@ function Get-GSDriveProfile { Defaults to the AdminEmail user + .PARAMETER Fields + The specific fields to request + .EXAMPLE Get-GSDriveProfile diff --git a/PSGSuite/Public/Drive/Get-GSDriveRevision.ps1 b/PSGSuite/Public/Drive/Get-GSDriveRevision.ps1 index 8b64b210..6fa0a985 100644 --- a/PSGSuite/Public/Drive/Get-GSDriveRevision.ps1 +++ b/PSGSuite/Public/Drive/Get-GSDriveRevision.ps1 @@ -12,13 +12,25 @@ function Get-GSDriveRevision { .PARAMETER RevisionId The unique Id of the revision to get. If excluded, gets the list of revisions for the file + .PARAMETER OutFilePath + The path to save the revision to + .PARAMETER User The email or unique Id of the owner of the Drive file Defaults to the AdminEmail user .PARAMETER Fields - The specific fields to returned + The specific fields to be returned + + .PARAMETER Force + If $true, overwrites any existing files at the desired path + + .PARAMETER PageSize + The maximum size of each page to return + + .PARAMETER Limit + The maximum amount of objects to return .EXAMPLE Get-GSDriveFile -FileId $fileId | Get-GSDriveRevision diff --git a/PSGSuite/Public/Drive/Update-GSDriveFile.ps1 b/PSGSuite/Public/Drive/Update-GSDriveFile.ps1 index 134e2132..29c07bb2 100644 --- a/PSGSuite/Public/Drive/Update-GSDriveFile.ps1 +++ b/PSGSuite/Public/Drive/Update-GSDriveFile.ps1 @@ -64,6 +64,9 @@ function Update-GSDriveFile { Only the owner may trash a file, and other users cannot see files in the owner's trash. + .PARAMETER WritersCanShare + If $true, sets Writers Can Share to true on the file. + .PARAMETER Projection The defined subset of fields to be returned diff --git a/PSGSuite/Public/Gmail/Get-GSGmailLanguageSettings.ps1 b/PSGSuite/Public/Gmail/Get-GSGmailLanguageSettings.ps1 new file mode 100644 index 00000000..7db8086a --- /dev/null +++ b/PSGSuite/Public/Gmail/Get-GSGmailLanguageSettings.ps1 @@ -0,0 +1,57 @@ +function Get-GSGmailLanguageSettings { + <# + .SYNOPSIS + Gets Gmail display language settings + + .DESCRIPTION + Gets Gmail display language settings + + .PARAMETER User + The user to get the Gmail display language settings for. + + Defaults to the AdminEmail user. + + .EXAMPLE + Get-GSGmailLanguageSettings -User me + + Gets the Gmail display language for the AdminEmail user. + #> + [OutputType('Google.Apis.Gmail.v1.Data.LanguageSettings')] + [cmdletbinding()] + Param ( + [parameter(Position = 0,ValueFromPipelineByPropertyName = $true)] + [Alias("PrimaryEmail","UserKey","Mail")] + [ValidateNotNullOrEmpty()] + [string[]] + $User = $Script:PSGSuite.AdminEmail + ) + 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/gmail.settings.basic' + ServiceType = 'Google.Apis.Gmail.v1.GmailService' + User = $U + } + $service = New-GoogleService @serviceParams + try { + $request = $service.Users.Settings.GetLanguage($U) + Write-Verbose "Getting Gmail Display Language for user '$U'" + $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $U -PassThru + } + catch { + if ($ErrorActionPreference -eq 'Stop') { + $PSCmdlet.ThrowTerminatingError($_) + } + else { + Write-Error $_ + } + } + } + } +} diff --git a/PSGSuite/Public/Gmail/Get-GSGmailMessageList.ps1 b/PSGSuite/Public/Gmail/Get-GSGmailMessageList.ps1 index 512092d5..dcc23eac 100644 --- a/PSGSuite/Public/Gmail/Get-GSGmailMessageList.ps1 +++ b/PSGSuite/Public/Gmail/Get-GSGmailMessageList.ps1 @@ -12,10 +12,13 @@ function Get-GSGmailMessageList { Defaults to the AdminEmail user .PARAMETER Filter - Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread" + Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread" More info on Gmail search operators here: https://support.google.com/mail/answer/7190?hl=en + .PARAMETER Rfc822MsgId + The RFC822 Message ID to add to your filter. + .PARAMETER LabelIds Only return messages with labels that match all of the specified label IDs diff --git a/PSGSuite/Public/Gmail/Update-GSGmailLanguageSettings.ps1 b/PSGSuite/Public/Gmail/Update-GSGmailLanguageSettings.ps1 new file mode 100644 index 00000000..81383c88 --- /dev/null +++ b/PSGSuite/Public/Gmail/Update-GSGmailLanguageSettings.ps1 @@ -0,0 +1,69 @@ +function Update-GSGmailLanguageSettings { + <# + .SYNOPSIS + Updates Gmail display language settings + + .DESCRIPTION + Updates Gmail display language settings + + .PARAMETER User + The user to update the Gmail display language settings for + + .PARAMETER Language + The language to display Gmail in, formatted as an RFC 3066 Language Tag (for example en-GB, fr or ja for British English, French, or Japanese respectively). + + The set of languages supported by Gmail evolves over time, so please refer to the "Language" dropdown in the Gmail settings for all available options, as described in the language settings help article. A table of sample values is also provided in the Managing Language Settings guide + + Not all Gmail clients can display the same set of languages. In the case that a user's display language is not available for use on a particular client, said client automatically chooses to display in the closest supported variant (or a reasonable default). + + .EXAMPLE + Update-GSGmailLanguageSettings -User me -Language fr + + Updates the Gmail display language to French for the AdminEmail user. + #> + [OutputType('Google.Apis.Gmail.v1.Data.LanguageSettings')] + [cmdletbinding()] + Param ( + [parameter(Mandatory,Position = 0,ValueFromPipelineByPropertyName = $true)] + [Alias("PrimaryEmail","UserKey","Mail")] + [ValidateNotNullOrEmpty()] + [string[]] + $User, + [parameter(Mandatory,Position = 1)] + [ValidateSet('af','am','ar','az','bg','bn','ca','chr','cs','cy','da','de','el','en','en-GB','es','es-419','et','eu','fa','fi','fil','fr','fr-CA','ga','gl','gu','he','hi','hr','hu','hy','id','is','it','ja','ka','km','kn','ko','lo','lt','lv','ml','mn','mr','ms','my','ne','nl','no','pl','pt-BR','pt-PT','ro','ru','si','sk','sl','sr','sv','sw','ta','te','th','tr','uk','ur','vi','zh-CN','zh-HK','zh-TW','zu')] + [string] + $Language + ) + 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/gmail.settings.basic' + ServiceType = 'Google.Apis.Gmail.v1.GmailService' + User = $U + } + $service = New-GoogleService @serviceParams + try { + $body = New-Object 'Google.Apis.Gmail.v1.Data.LanguageSettings' -Property @{ + DisplayLanguage = $Language + } + $request = $service.Users.Settings.UpdateLanguage($body,$U) + Write-Verbose "Updating Gmail Display Language for user '$U' to '$Language'" + $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $U -PassThru + } + catch { + if ($ErrorActionPreference -eq 'Stop') { + $PSCmdlet.ThrowTerminatingError($_) + } + else { + Write-Error $_ + } + } + } + } +} diff --git a/PSGSuite/Public/Helpers/Add-GSCalendarEventReminder.ps1 b/PSGSuite/Public/Helpers/Add-GSCalendarEventReminder.ps1 new file mode 100644 index 00000000..65207fec --- /dev/null +++ b/PSGSuite/Public/Helpers/Add-GSCalendarEventReminder.ps1 @@ -0,0 +1,71 @@ +function Add-GSCalendarEventReminder { + <# + .SYNOPSIS + Builds an EventReminder object to use when creating or updating a CalendarSubscription or CalendarEvent + + .DESCRIPTION + Builds an EventReminder object to use when creating or updating a CalendarSubscription or CalendarEvent + + .PARAMETER Method + The method used by this reminder. Defaults to email. + + Possible values are: + * "email" - Reminders are sent via email. + * "sms" - Reminders are sent via SMS. These are only available for G Suite customers. Requests to set SMS reminders for other account types are ignored. + * "popup" - Reminders are sent via a UI popup. + + .PARAMETER Minutes + Number of minutes before the start of the event when the reminder should trigger. Defaults to 30 minutes. + + Valid values are between 0 and 40320 (4 weeks in minutes). + + .PARAMETER InputObject + Used for pipeline input of an existing IM object to strip the extra attributes and prevent errors + + .EXAMPLE + + #> + [OutputType('Google.Apis.Calendar.v3.Data.EventReminder')] + [CmdletBinding()] + Param + ( + [Parameter(Mandatory, ParameterSetName = "Fields")] + [ValidateSet('email','sms','popup')] + [String] + $Method, + [Parameter(Mandatory, ParameterSetName = "Fields")] + [Int] + $Minutes, + [Parameter(ValueFromPipeline, ParameterSetName = "InputObject")] + [Google.Apis.Calendar.v3.Data.EventReminder[]] + $InputObject + ) + Process { + try { + switch ($PSCmdlet.ParameterSetName) { + Fields { + New-Object 'Google.Apis.Calendar.v3.Data.EventReminder' -Property @{ + Method = $Method + Minutes = $Minutes + } + } + InputObject { + foreach ($iObj in $InputObject) { + New-Object 'Google.Apis.Calendar.v3.Data.EventReminder' -Property @{ + Method = $iObj.Method + Minutes = $iObj.Minutes + } + } + } + } + } + catch { + if ($ErrorActionPreference -eq 'Stop') { + $PSCmdlet.ThrowTerminatingError($_) + } + else { + Write-Error $_ + } + } + } +} diff --git a/PSGSuite/Public/Helpers/Add-GSCalendarNotification.ps1 b/PSGSuite/Public/Helpers/Add-GSCalendarNotification.ps1 new file mode 100644 index 00000000..2b791bc3 --- /dev/null +++ b/PSGSuite/Public/Helpers/Add-GSCalendarNotification.ps1 @@ -0,0 +1,76 @@ +function Add-GSCalendarNotification { + <# + .SYNOPSIS + Builds an CalendarNotification object to use when creating or updating a CalendarSubscription + + .DESCRIPTION + Builds an CalendarNotification object to use when creating or updating a CalendarSubscription + + .PARAMETER Method + The method used to deliver the notification. + + Possible values are: + * "email" - Reminders are sent via email. + * "sms" - Reminders are sent via SMS. This value is read-only and is ignored on inserts and updates. SMS reminders are only available for G Suite customers. + + .PARAMETER Type + The type of notification. + + Possible values are: + * "eventCreation" - Notification sent when a new event is put on the calendar. + * "eventChange" - Notification sent when an event is changed. + * "eventCancellation" - Notification sent when an event is cancelled. + * "eventResponse" - Notification sent when an event is changed. + * "agenda" - An agenda with the events of the day (sent out in the morning). + + .PARAMETER InputObject + Used for pipeline input of an existing IM object to strip the extra attributes and prevent errors + + .EXAMPLE + + #> + [OutputType('Google.Apis.Calendar.v3.Data.CalendarNotification')] + [CmdletBinding()] + Param + ( + [Parameter(Mandatory, ParameterSetName = "Fields")] + [ValidateSet('email','sms')] + [String] + $Method, + [Parameter(Mandatory, ParameterSetName = "Fields")] + [ValidateSet('eventCreation','eventChange','eventCancellation','eventResponse','agenda')] + [String] + $Type, + [Parameter(ValueFromPipeline, ParameterSetName = "InputObject")] + [Google.Apis.Calendar.v3.Data.CalendarNotification[]] + $InputObject + ) + Process { + try { + switch ($PSCmdlet.ParameterSetName) { + Fields { + New-Object 'Google.Apis.Calendar.v3.Data.CalendarNotification' -Property @{ + Method = $Method + Type = $Type + } + } + InputObject { + foreach ($iObj in $InputObject) { + New-Object 'Google.Apis.Calendar.v3.Data.CalendarNotification' -Property @{ + Method = $iObj.Method + Type = $iObj.Type + } + } + } + } + } + catch { + if ($ErrorActionPreference -eq 'Stop') { + $PSCmdlet.ThrowTerminatingError($_) + } + else { + Write-Error $_ + } + } + } +} diff --git a/PSGSuite/Public/Helpers/Add-GSCustomerPostalAddress.ps1 b/PSGSuite/Public/Helpers/Add-GSCustomerPostalAddress.ps1 index ada64300..50d4e457 100644 --- a/PSGSuite/Public/Helpers/Add-GSCustomerPostalAddress.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSCustomerPostalAddress.ps1 @@ -35,6 +35,9 @@ function Add-GSCustomerPostalAddress { .PARAMETER InputObject Used for pipeline input of an existing UserAddress object to strip the extra attributes and prevent errors + + .EXAMPLE + Add-GSCustomerPostalAddress -AddressLine1 '123 Front St' -AddressLine2 'Los Angeles, CA 90210' -ContactName 'Jim' #> [OutputType('Google.Apis.Admin.Directory.directory_v1.Data.CustomerPostalAddress')] [CmdletBinding(DefaultParameterSetName = "InputObject")] diff --git a/PSGSuite/Public/Helpers/Add-GSEventAttendee.ps1 b/PSGSuite/Public/Helpers/Add-GSEventAttendee.ps1 index 6b7a534d..665b14f1 100644 --- a/PSGSuite/Public/Helpers/Add-GSEventAttendee.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSEventAttendee.ps1 @@ -38,6 +38,9 @@ function Add-GSEventAttendee { .PARAMETER InputObject Used for pipeline input of an existing UserAddress object to strip the extra attributes and prevent errors + + .EXAMPLE + Add-GSEventAttendee -Email 'joe@domain.com' #> [OutputType('Google.Apis.Calendar.v3.Data.EventAttendee')] [CmdletBinding(DefaultParameterSetName = "InputObject")] diff --git a/PSGSuite/Public/Helpers/Add-GSGmailSmtpMsa.ps1 b/PSGSuite/Public/Helpers/Add-GSGmailSmtpMsa.ps1 index e6180604..b0c42728 100644 --- a/PSGSuite/Public/Helpers/Add-GSGmailSmtpMsa.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSGmailSmtpMsa.ps1 @@ -6,7 +6,7 @@ function Add-GSGmailSmtpMsa { .DESCRIPTION Builds a SmtpMsa object to use when creating or updating SmtpMsa settings withing the Gmail SendAs settings. - .PARAMETER Host + .PARAMETER HostName The hostname of the SMTP service. .PARAMETER Port diff --git a/PSGSuite/Public/Helpers/Add-GSUserAddress.ps1 b/PSGSuite/Public/Helpers/Add-GSUserAddress.ps1 index aaab6558..e2b3c1f0 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserAddress.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserAddress.ps1 @@ -43,13 +43,13 @@ function Add-GSUserAddress { The street address, such as 1600 Amphitheatre Parkway. Whitespace within the string is ignored; however, newlines are significant .PARAMETER Type - The address type. + The address type. Acceptable values are: - * "Custom" - * "Home" - * "Other" - * "Work" + * "custom" + * "home" + * "other" + * "work" .PARAMETER InputObject Used for pipeline input of an existing UserAddress object to strip the extra attributes and prevent errors @@ -110,7 +110,7 @@ function Add-GSUserAddress { [String] $StreetAddress, [Parameter(Mandatory = $false, ParameterSetName = "Fields")] - [ValidateSet('Custom', 'Home', 'Other', 'Work')] + [ValidateSet('custom', 'home', 'other', 'work')] [String] $Type, [Parameter(Mandatory = $false, ValueFromPipeline = $true, ParameterSetName = "InputObject")] @@ -140,7 +140,12 @@ function Add-GSUserAddress { Fields { $obj = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.UserAddress' foreach ($prop in $PSBoundParameters.Keys | Where-Object {$obj.PSObject.Properties.Name -contains $_}) { - $obj.$prop = $PSBoundParameters[$prop] + if ($prop -eq 'Type') { + $obj.$prop = $PSBoundParameters[$prop].ToLower() + } + else { + $obj.$prop = $PSBoundParameters[$prop] + } } $obj } diff --git a/PSGSuite/Public/Helpers/Add-GSUserEmail.ps1 b/PSGSuite/Public/Helpers/Add-GSUserEmail.ps1 index bc20fc53..19661a6f 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserEmail.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserEmail.ps1 @@ -74,7 +74,12 @@ function Add-GSUserEmail { Fields { $obj = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.UserEmail' foreach ($prop in $PSBoundParameters.Keys | Where-Object {$obj.PSObject.Properties.Name -contains $_}) { - $obj.$prop = $PSBoundParameters[$prop] + if ($prop -eq 'Type') { + $obj.$prop = $PSBoundParameters[$prop].ToLower() + } + else { + $obj.$prop = $PSBoundParameters[$prop] + } } $obj } diff --git a/PSGSuite/Public/Helpers/Add-GSUserExternalId.ps1 b/PSGSuite/Public/Helpers/Add-GSUserExternalId.ps1 index ab3c64d1..046c5df4 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserExternalId.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserExternalId.ps1 @@ -71,7 +71,12 @@ function Add-GSUserExternalId { Fields { $obj = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.UserExternalId' foreach ($prop in $PSBoundParameters.Keys | Where-Object {$obj.PSObject.Properties.Name -contains $_}) { - $obj.$prop = $PSBoundParameters[$prop] + if ($prop -eq 'Type') { + $obj.$prop = $PSBoundParameters[$prop].ToLower() + } + else { + $obj.$prop = $PSBoundParameters[$prop] + } } $obj } diff --git a/PSGSuite/Public/Helpers/Add-GSUserIm.ps1 b/PSGSuite/Public/Helpers/Add-GSUserIm.ps1 index a71432c1..0786a7c4 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserIm.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserIm.ps1 @@ -107,7 +107,12 @@ function Add-GSUserIm { Fields { $obj = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.UserIm' foreach ($prop in $PSBoundParameters.Keys | Where-Object {$obj.PSObject.Properties.Name -contains $_}) { - $obj.$prop = $PSBoundParameters[$prop] + if ($prop -in @('Type','Protocol')) { + $obj.$prop = $PSBoundParameters[$prop].ToLower() + } + else { + $obj.$prop = $PSBoundParameters[$prop] + } } $obj } diff --git a/PSGSuite/Public/Helpers/Add-GSUserLocation.ps1 b/PSGSuite/Public/Helpers/Add-GSUserLocation.ps1 index 52b08b0d..88a382d6 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserLocation.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserLocation.ps1 @@ -87,7 +87,12 @@ function Add-GSUserLocation { Fields { $obj = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.UserLocation' foreach ($prop in $PSBoundParameters.Keys | Where-Object {$obj.PSObject.Properties.Name -contains $_}) { - $obj.$prop = $PSBoundParameters[$prop] + if ($prop -eq 'Type') { + $obj.$prop = $PSBoundParameters[$prop].ToLower() + } + else { + $obj.$prop = $PSBoundParameters[$prop] + } } $obj } diff --git a/PSGSuite/Public/Helpers/Add-GSUserOrganization.ps1 b/PSGSuite/Public/Helpers/Add-GSUserOrganization.ps1 index 9a8a30d7..86dcb5cd 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserOrganization.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserOrganization.ps1 @@ -6,9 +6,39 @@ function Add-GSUserOrganization { .DESCRIPTION Builds a Organization object to use when creating or updating a User + .PARAMETER CostCenter + The cost center of the users department + .PARAMETER CustomType If the external ID type is custom, this property holds the custom type + .PARAMETER Department + Department within the organization + + .PARAMETER Description + Description of the organization + + .PARAMETER Domain + The domain to which the organization belongs to + + .PARAMETER FullTimeEquivalent + The full-time equivalent percent within the organization (100000 = 100%). + + .PARAMETER Location + Location of the organization. This need not be fully qualified address. + + .PARAMETER Name + Name of the organization + + .PARAMETER Primary + If it is the user's primary organization + + .PARAMETER Symbol + Symbol of the organization + + .PARAMETER Title + Title (designation) of the user in the organization + .PARAMETER Type The type of the organization. diff --git a/PSGSuite/Public/Helpers/Add-GSUserPhone.ps1 b/PSGSuite/Public/Helpers/Add-GSUserPhone.ps1 index 4cdc65b4..7923fc66 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserPhone.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserPhone.ps1 @@ -92,7 +92,12 @@ function Add-GSUserPhone { Fields { $obj = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.UserPhone' foreach ($prop in $PSBoundParameters.Keys | Where-Object {$obj.PSObject.Properties.Name -contains $_}) { - $obj.$prop = $PSBoundParameters[$prop] + if ($prop -eq 'Type') { + $obj.$prop = $PSBoundParameters[$prop].ToLower() + } + else { + $obj.$prop = $PSBoundParameters[$prop] + } } $obj } diff --git a/PSGSuite/Public/Helpers/Add-GSUserRelation.ps1 b/PSGSuite/Public/Helpers/Add-GSUserRelation.ps1 index 47dcc66f..405d333d 100644 --- a/PSGSuite/Public/Helpers/Add-GSUserRelation.ps1 +++ b/PSGSuite/Public/Helpers/Add-GSUserRelation.ps1 @@ -65,9 +65,6 @@ function Add-GSUserRelation { [Parameter(Mandatory = $false, ParameterSetName = "Fields")] [String] $CustomType, - [Parameter(Mandatory = $false, ParameterSetName = "Fields")] - [String] - $ETag, [Parameter(Mandatory = $false, ValueFromPipeline = $true, ParameterSetName = "InputObject")] [Google.Apis.Admin.Directory.directory_v1.Data.UserRelation[]] $InputObject @@ -77,7 +74,6 @@ function Add-GSUserRelation { 'CustomType' 'Type', 'Value' - 'ETag' ) if ($PSBoundParameters.Keys -contains 'CustomType') { $PSBoundParameters['Type'] = 'custom' diff --git a/PSGSuite/Public/Helpers/Compare-ModuleVersion.ps1 b/PSGSuite/Public/Helpers/Compare-ModuleVersion.ps1 index e0f1a28c..99717feb 100644 --- a/PSGSuite/Public/Helpers/Compare-ModuleVersion.ps1 +++ b/PSGSuite/Public/Helpers/Compare-ModuleVersion.ps1 @@ -1,4 +1,17 @@ function Compare-ModuleVersion { + <# + .SYNOPSIS + Compares the installed version of a module with the latest version on the PowerShell Gallery + + .DESCRIPTION + Compares the installed version of a module with the latest version on the PowerShell Gallery + + .PARAMETER ModuleName + The name of the module to compare + + .EXAMPLE + Compare-ModuleVersion PSGSuite + #> [CmdletBinding()] Param ( @@ -40,4 +53,4 @@ function Compare-ModuleVersion { End { return $results } -} \ No newline at end of file +} diff --git a/PSGSuite/Public/Reports/Get-GSActivityReport.ps1 b/PSGSuite/Public/Reports/Get-GSActivityReport.ps1 index b1faa3af..65cb00fb 100644 --- a/PSGSuite/Public/Reports/Get-GSActivityReport.ps1 +++ b/PSGSuite/Public/Reports/Get-GSActivityReport.ps1 @@ -31,6 +31,9 @@ function Get-GSActivityReport { .PARAMETER ActorIpAddress IP Address of host where the event was performed. Supports both IPv4 and IPv6 addresses + .PARAMETER StartTime + Return events which occurred after this time + .PARAMETER EndTime Return events which occurred at or before this time diff --git a/PSGSuite/Public/Reports/Get-GSUsageReport.ps1 b/PSGSuite/Public/Reports/Get-GSUsageReport.ps1 index bae1ae6f..783ff367 100644 --- a/PSGSuite/Public/Reports/Get-GSUsageReport.ps1 +++ b/PSGSuite/Public/Reports/Get-GSUsageReport.ps1 @@ -39,6 +39,12 @@ function Get-GSUsageReport { .PARAMETER Limit The maximum amount of results you want returned. Exclude or set to 0 to return all results + .PARAMETER Flat + If $true, returns a flattened object for easy parsing. + + .PARAMETER Raw + If $true, returns the raw, unformatted results. + .EXAMPLE Get-GSUsageReport -Date (Get-Date).AddDays(-30) diff --git a/PSGSuite/Public/Tasks/Get-GSTask.ps1 b/PSGSuite/Public/Tasks/Get-GSTask.ps1 index e5474d3d..9ed9c488 100644 --- a/PSGSuite/Public/Tasks/Get-GSTask.ps1 +++ b/PSGSuite/Public/Tasks/Get-GSTask.ps1 @@ -6,11 +6,6 @@ function Get-GSTask { .DESCRIPTION Gets a specific Task or the list of Tasks - .PARAMETER User - The User who owns the Task. - - Defaults to the AdminUser's email. - .PARAMETER Task The unique Id of the Task. @@ -19,6 +14,35 @@ function Get-GSTask { .PARAMETER Tasklist The unique Id of the Tasklist the Task is on. + .PARAMETER User + The User who owns the Task. + + Defaults to the AdminUser's email. + + .PARAMETER CompletedMax + Upper bound for a task's completion date to filter by. + + .PARAMETER CompletedMin + Lower bound for a task's completion date to filter by. + + .PARAMETER DueMax + Upper bound for a task's due date to filter by. + + .PARAMETER DueMin + Lower bound for a task's due date to filter by. + + .PARAMETER UpdatedMin + Lower bound for a task's last modification time to filter by. + + .PARAMETER ShowCompleted + Flag indicating whether completed tasks are returned in the result. + + .PARAMETER ShowDeleted + Flag indicating whether deleted tasks are returned in the result. + + .PARAMETER ShowHidden + Flag indicating whether hidden tasks are returned in the result. + .PARAMETER PageSize Page size of the result set diff --git a/README.md b/README.md index 1bc63106..e3fd0167 100644 --- a/README.md +++ b/README.md @@ -158,36 +158,26 @@ 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.31.1 - 2019-08-30 - -* [Issue #222](https://github.com/scrthq/PSGSuite/issues/222) - * Fixed: `Remove-GSUserASP` and `Remove-GSUserToken` not removing all when no Id is passed due to no service being created. -* [Issue #225](https://github.com/scrthq/PSGSuite/issues/225) - * Added: `RecoveryEmail` and `RecoveryPhone` parameters to `Update-GSUser` -* [Issue #189](https://github.com/scrthq/PSGSuite/issues/189) - * Removed `$env:UserName` from the application name when creating the client in `New-GoogleService` to prevent errors with the underlying .NET SDK. +#### 2.32.0 - 2019-09-12 + +* [Issue #229](https://github.com/scrthq/PSGSuite/issues/229) + * Added: `Update-GSGmailLanguageSettings` and `Get-GSGmailLanguageSettings` functions to update/get a users default language settings in Gmail. +* [Issue #231](https://github.com/scrthq/PSGSuite/issues/231) + * Added: `Update-GSCalenderSubscription` function to updated existing calendar subscriptions. + * Removed: Default values for the following parameters on `Add-GSCalendarSubscription` to prevent automatically adding notifications for new CalendarList entries (subscriptions): + * `DefaultNotificationType` + * `DefaultNotificationMethod` + * `DefaultReminderMethod` + * `DefaultReminderMinutes` + * Added: `Notifications` and `Reminders` parameters to `Add-GSCalenderSubscription` and `Update-GSCalenderSubscription` + * Added: `Reminders` parameter to `New-GSCalendarEvent` and `Update-GSCalendarEvent` functions to set custom reminders on calendar events. + * Added: `Add-GSCalendarEventReminder` and `Add-GSCalendarNotification` helper functions. + * Updated: `DisableReminder` switch parameter name on `New-GSCalendarEvent` and `Update-GSCalendarEvent` functions to `DisableDefaultReminder` to better align with what that actually effects (default reminder inheritance only, not reminder overrides). The previous parameter name has been set as an alias to maintain backwards compatibility. + * Added: `RemoveAllReminders` parameter to `Update-GSCalendarEvent` to remove all custom reminders and disable calendar inheritance. +* [Issue #232](https://github.com/scrthq/PSGSuite/issues/232) + * Added: `Visibility` parameter on `New-GSCalendarEvent` and `Update-GSCalendarEvent` to set the visibility of a calendar event. * Miscellaneous - * Fixed: Corrected logic on the `FullName` parameter on `Update-GSUser` to parse the name parts. + * Forced `Type` parameter values to lower on the `Add-GSUser*` helper functions to ensure case senstive field matches whats expected. * Updated Google .NET SDKs to latest versions. - -#### 2.31.0 - -* [Issue #218](https://github.com/scrthq/PSGSuite/issues/218) - * Fixed: `Update-GSOrganizationalUnit` was failing with `null` reference errors. -* [Issue #213](https://github.com/scrthq/PSGSuite/issues/213) - * Added: Support for `RELEASE_RESOURCES` TransferParam for Calendar application data transfers to function `Start-GSDataTransfer` -* [Issue #215](https://github.com/scrthq/PSGSuite/issues/215) - * Added: - * `Get-GSDomain` - * `Remove-GSDomain` - * `New-GSDomain` - * `Get-GSDomainAlias` - * `New-GSDomainAlias` - * `Remove-GSDomainAlias` - * _These will need the additional scope of `https://www.googleapis.com/auth/admin.directory.domain` added in order to use!_ -* Miscellaneous - * Added: - * `Get-GSCustomer` - * `Update-GSCustomer` - * `Add-GSCustomerPostalAddress` - * _These will need the additional scope of `https://www.googleapis.com/auth/admin.directory.customer` added in order to use!_ + * Updated and corrected a LOT of comment based function help. + * Added function help tests to validate that functions contain expected help content. diff --git a/Tests/1. Module Tests/PSGSuite.Help.Tests.ps1 b/Tests/1. Module Tests/PSGSuite.Help.Tests.ps1 new file mode 100644 index 00000000..dd717da0 --- /dev/null +++ b/Tests/1. Module Tests/PSGSuite.Help.Tests.ps1 @@ -0,0 +1,44 @@ +$ModuleName = 'PSGSuite' +$ProjectRoot = Resolve-Path "$PSScriptRoot\..\.." | Select-Object -ExpandProperty Path +$SourceModulePath = Resolve-Path "$ProjectRoot\$ModuleName" | Select-Object -ExpandProperty Path +$TargetModulePath = Get-ChildItem "$ProjectRoot\BuildOutput\$($ModuleName)" | Sort-Object { [Version]$_.Name } | Select-Object -Last 1 -ExpandProperty FullName + +Describe "Public Function Help tests" { + # Adapted from Francois' post here: https://lazywinadmin.com/2016/05/using-pester-to-test-your-comment-based.html + Import-Module "$TargetModulePath\$($ModuleName).psd1" -Force -ErrorAction SilentlyContinue + $FunctionsList = (Get-Module $ModuleName).ExportedFunctions.Keys + foreach ($Function in $FunctionsList) { + $Help = Get-Help -Name $Function -Full + $AST = [System.Management.Automation.Language.Parser]::ParseInput((Get-Content function:$Function), [ref]$null, [ref]$null) + Context "$Function - Help" { + It "Synopsis" { + $Help.Synopsis | Should -Not -BeNullOrEmpty + } + It "Description" { + $Help.Description | Should -Not -BeNullOrEmpty + } + $RiskMitigationParameters = 'Whatif', 'Confirm' + $HelpParameters = $Help.Parameters.Parameter | Where-Object {$_.Name -notin $RiskMitigationParameters} + $ASTParameters = $ast.ParamBlock.Parameters.Name.variablepath.userpath + It "Parameter - Compare Count Help/AST" { + $HelpParameters.Name.Count -eq $ASTParameters.Count | Should Be $true + } + If (-not [String]::IsNullOrEmpty($ASTParameters)) { # IF ASTParameters are found + $HelpParameters | ForEach-Object { + It "Parameter $($_.Name) - Should contain description" { + $_.Description | Should -Not -BeNullOrEmpty + } + } + + } + It "Example - Count should be greater than 0" { + $Help.Examples.Example.Code.Count | Should -BeGreaterThan 0 + } + foreach ($Example in $Help.examples.example) { + it "Example - Remarks on $(($Example.Title -replace '--------------------------').Trim())" { + $Example.Remarks | Should -Not -BeNullOrEmpty + } + } + } + } +} diff --git a/Tests/3. Integration Tests/PSGSuite.Integration.Tests.ps1 b/Tests/3. Integration Tests/PSGSuite.Integration.Tests.ps1 index f27db8cf..a9403d0a 100644 --- a/Tests/3. Integration Tests/PSGSuite.Integration.Tests.ps1 +++ b/Tests/3. Integration Tests/PSGSuite.Integration.Tests.ps1 @@ -1,5 +1,4 @@ -<# -if ($ENV:BUILD_BUILDURI -like 'vstfs:*') { +if ($ENV:BUILD_BUILDURI -like 'vstfs:*' -and -not [String]::IsNullOrEmpty($env:PSGSuiteConfig)) { $projectRoot = Resolve-Path "$PSScriptRoot\..\.." $ModulePath = Resolve-Path "$projectRoot\BuildOutput\$($env:BHProjectName)" $decompiledModulePath = Resolve-Path "$projectRoot\$($env:BHProjectName)" @@ -11,13 +10,14 @@ if ($ENV:BUILD_BUILDURI -like 'vstfs:*') { $moduleRoot = Split-Path (Resolve-Path "$ModulePath\*\*.psd1") Import-Module $ModulePath -Force -Verbose:$false - Import-PSGSuiteConfig -Json $env:PSGSuiteConfigJson -Temporary -Verbose + Import-PSGSuiteConfig -Json $env:PSGSuiteConfig -Temporary -Verbose $u = Get-GSUser $u | Select-Object @{N="GivenName";E={$_.Name.GivenName}},OrgUnitPath,Kind Send-GmailMessage -From $u.PrimaryEmail -To $u.PrimaryEmail -Subject "Hello from Azure Pipelines + PS Version $($PSVersionTable.PSVersion.ToString())!" -Body "
`n$((Get-ChildItem Env: | Where-Object {$_.Name -match '^(BUILD_|BH).*$'} | Format-Table -AutoSize | Out-String).Trim())`n
" -BodyAsHtml -Verbose } +<# Describe "Function contents" -Tag 'Module' { Context "Get-GSUser should return a user" { $scripts = Get-ChildItem "$decompiledModulePath\Public" -Include *.ps1 -Recurse | Where-Object {$_.FullName -notlike "*Helpers*"} diff --git a/build.ps1 b/build.ps1 index b1565b41..991a3387 100644 --- a/build.ps1 +++ b/build.ps1 @@ -38,6 +38,21 @@ else { $env:BuildScriptPath = $PSScriptRoot $env:NoNugetRestore = $NoRestore + Invoke-CommandWithLog {$global:PSDefaultParameterValues = @{ + '*-Module:Verbose' = $false + 'Import-Module:ErrorAction' = 'Stop' + 'Import-Module:Force' = $true + 'Import-Module:Verbose' = $false + 'Install-Module:AllowClobber' = $true + 'Install-Module:ErrorAction' = 'Stop' + 'Install-Module:Force' = $true + 'Install-Module:Scope' = 'CurrentUser' + 'Install-Module:Repository' = 'PSGallery' + 'Install-Module:Verbose' = $false + }} + Invoke-CommandWithLog {Get-PackageProvider -Name Nuget -ForceBootstrap -Verbose:$false} + Invoke-CommandWithLog {Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Verbose:$false} + Add-EnvironmentSummary "Build started" Set-BuildVariables @@ -48,28 +63,10 @@ else { PackageManagement = '1.4.4' PowerShellGet = '2.2.1' } - foreach ($module in $modHash.Keys | Sort-Object) { - Write-BuildLog "Updating $module module if needed" - if ($null -eq (Get-Module $module -ListAvailable | Where-Object {[System.Version]$_.Version -ge [System.Version]($modHash[$module])})) { - Write-BuildLog "$module is below the minimum required version! Updating" - Install-Module $module -MinimumVersion $modHash[$module] -Force -AllowClobber -SkipPublisherCheck -Scope CurrentUser -Verbose:$false - } + $modHash.GetEnumerator() | ForEach-Object { + Install-Module $_.Key -MinimumVersion $_.Value -Repository PSGallery -Force } - Invoke-CommandWithLog {Get-PackageProvider -Name Nuget -ForceBootstrap -Verbose:$false} - Invoke-CommandWithLog {Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Verbose:$false} - Invoke-CommandWithLog {$PSDefaultParameterValues = @{ - '*-Module:Verbose' = $false - 'Import-Module:ErrorAction' = 'Stop' - 'Import-Module:Force' = $true - 'Import-Module:Verbose' = $false - 'Install-Module:AllowClobber' = $true - 'Install-Module:ErrorAction' = 'Stop' - 'Install-Module:Force' = $true - 'Install-Module:Scope' = 'CurrentUser' - 'Install-Module:Verbose' = $false - }} - Add-Heading "Finalizing build prerequisites" if ( $Task -eq 'Deploy' -and -not $Force -and (