Skip to content

Commit 9db5d3e

Browse files
New-AzAutomationSchedule provide ability to define the start time with offsets (Azure#16526)
* Update AutomationPSClient.cs * Update New-AzAutomationSchedule.md * Update New-AzAutomationSchedule.md * Update New-AzAutomationSchedule.md * Update ChangeLog.md
1 parent c5a9139 commit 9db5d3e

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/Automation/Automation/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* `New-AzAutomationSchedule` allows defnining StartTime with offsets.
2122
* Fixed example in reference doc for `Remove-AzAutomationHybridWorkerGroup`
2223

2324
## Version 1.7.1

src/Automation/Automation/Common/AutomationPSClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ public void DeleteModule(string resourceGroupName, string automationAccountName,
436436

437437
public Schedule CreateSchedule(string resourceGroupName, string automationAccountName, Schedule schedule)
438438
{
439-
var scheduleCreateOrUpdateParameters = new AutomationManagement.Models.ScheduleCreateOrUpdateParameters
439+
var scheduleCreateOrUpdateParameters = new ScheduleCreateOrUpdateParameters
440440
{
441441
Name = schedule.Name,
442-
StartTime = schedule.StartTime.DateTime,
442+
StartTime = schedule.StartTime,
443443
ExpiryTime = schedule.ExpiryTime,
444444
Description = schedule.Description,
445445
Interval = schedule.Interval,

src/Automation/Automation/help/New-AzAutomationSchedule.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,19 @@ PS C:\> New-AzAutomationSchedule -AutomationAccountName "Contoso17" -Name "Sched
7272
```
7373

7474
The first command gets the time zone ID from the system and stores it in the $TimeZone variable.
75-
The second command creates a schedule that runs one time on the current date at 11:00 PM in the specified time zone..
75+
The second command creates a schedule that runs one time on the current date at 11:00 PM in the specified time zone.
7676

77-
### Example 2: Create a recurring schedule
77+
### Example 2: Create a one-time schedule in another time zone
78+
```
79+
PS C:\> $TimeZone = "Europe/Paris"
80+
PS C:\> New-AzAutomationSchedule -AutomationAccountName "Contoso17" -Name "Schedule01" -StartTime "23:00Z" -OneTime -ResourceGroupName "ResourceGroup01" -TimeZone $TimeZone
81+
```
82+
83+
The first command initializes a $TimeZone variable with value `Europe/Paris`
84+
The second command creates a schedule that runs one time on the current date at 23:00 UTC in the specified time zone.
85+
> Note: Schedule *StartTime* is calculated by adding the *TimeZone* Offset to provided *StartTime*
86+
87+
### Example 3: Create a recurring schedule
7888
```
7989
PS C:\> $StartTime = Get-Date "13:00:00"
8090
PS C:\> $EndTime = $StartTime.AddYears(1)
@@ -87,7 +97,7 @@ The second command creates a date object by using the **Get-Date** cmdlet, and t
8797
The command specifies a future time.
8898
The final command creates a daily schedule named Schedule02 to begin at the time stored in $StartDate and expire at the time stored in $EndDate.
8999

90-
### Example 3: Create a weekly recurring schedule
100+
### Example 4: Create a weekly recurring schedule
91101
```
92102
PS C:\> $StartTime = (Get-Date "13:00:00").AddDays(1)
93103
PS C:\> [System.DayOfWeek[]]$WeekDays = @([System.DayOfWeek]::Monday..[System.DayOfWeek]::Friday)
@@ -345,7 +355,7 @@ Accept wildcard characters: False
345355
### -StartTime
346356
Specifies the start time of a schedule as a **DateTimeOffset** object.
347357
You can specify a string that can be converted to a valid **DateTimeOffset**.
348-
If the *TimeZone* parameter is specified, the offset will be ignored and the time zone specified is used.
358+
If the *TimeZone* is provided, *StartTime* is calculated by adding the Offset of Input *TimeZone*.
349359
350360
```yaml
351361
Type: System.DateTimeOffset

0 commit comments

Comments
 (0)