-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add calendar event move #367
Open
dwrusse
wants to merge
8
commits into
SCRT-HQ:main
Choose a base branch
from
dwrusse:feat/add_calendar_event_move
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad605e7
Merge pull request #3 from scrthq/master
dwrusse 9f4a1e9
added import-gsgmailmessage
c1d9be9
Merge remote-tracking branch 'upstream/main'
dwrusse 0c306fb
added move-gscalendarevent function
dwrusse 9c8057b
updated parameter name to DestinationCalendarId
dwrusse 7af98ef
updated version number
dwrusse 450c3bc
corrected version numbers
dwrusse 304ea95
Delete Import-GSGmailMessage.ps1
dwrusse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
function Move-GSCalendarEvent { | ||
<# | ||
.SYNOPSIS | ||
Moves an event to a new calendar (updates the Organizer). | ||
|
||
.DESCRIPTION | ||
Moves an event to a new calendar (updates the Organizer). | ||
|
||
.PARAMETER CalendarID | ||
The Id of the source calendar. | ||
|
||
Defaults to the user's primary calendar. | ||
|
||
.PARAMETER EventID | ||
The unique Id of the event to update | ||
|
||
.PARAMETER DestinationCalendarId | ||
The Id of the destination 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. | ||
|
||
User must have access to both calendars. Recommend using admin. | ||
|
||
.PARAMETER SendUpdates | ||
Whether to send update notifications to the attendees. | ||
|
||
Possible values are: | ||
* "none" - No notifications are sent. | ||
* "externalOnly" - Notifications are sent to non-Google Calendar guests only. | ||
* "all" - Notifications are sent to all guests. | ||
|
||
.EXAMPLE | ||
Move-GSCalendarEvent -CalendarId [email protected] -EventId bcfgr7j83oqpv8174bnamv63pj -DestinationCalendarId [email protected] | ||
|
||
Moves the event with eventId "bcfgr7j83oqpv8174bnamv63pj" from calendar "[email protected]" to calendar "[email protected]" | ||
#> | ||
[OutputType('Google.Apis.Calendar.v3.Data.Event')] | ||
[cmdletbinding(DefaultParameterSetName = "AttendeeEmails")] | ||
Param | ||
( | ||
[parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] | ||
[Alias('Id')] | ||
[String] | ||
$EventId, | ||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[String] | ||
$CalendarId = "primary", | ||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[Alias("PrimaryEmail", "UserKey", "Mail")] | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$User = $Script:PSGSuite.AdminEmail, | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $false)] | ||
[String] | ||
$DestinationCalendarId, | ||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $false)] | ||
[ValidateSet("none", "all", "externalOnly")] | ||
[String] | ||
$SendUpdates = "none" | ||
) | ||
Process { | ||
try { | ||
if ($Uuser -ceq 'me') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a typo, I would assume this should be |
||
$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 | ||
Write-Verbose "Moving Calendar Event '$EventId' on calendar '$CalendarId' for user '$User' to calendar '$DestinationCalendarId'" | ||
$request = $service.Events.Move($CalendarId, $EventId, $DestinationCalendarId) | ||
$request.SendUpdates = $SendUpdates | ||
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru | Add-Member -MemberType NoteProperty -Name 'CalendarId' -Value $DestinationCalendarId -PassThru | ||
} | ||
catch { | ||
if ($ErrorActionPreference -eq 'Stop') { | ||
$PSCmdlet.ThrowTerminatingError($_) | ||
} | ||
else { | ||
Write-Error $_ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's no parameter sets defined, so while this doesn't hurt anything, it doesn't do anything either.