共用方式為


New-AzAutomationSchedule

建立自動化排程。

語法

New-AzAutomationSchedule
   [-Name] <String>
   [-StartTime] <DateTimeOffset>
   [-Description <String>]
   [-ExpiryTime <DateTimeOffset>]
   -DayInterval <Byte>
   [-TimeZone <String>]
   [-ForUpdateConfiguration]
   [-ResourceGroupName] <String>
   [-AutomationAccountName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzAutomationSchedule
   [-Name] <String>
   [-StartTime] <DateTimeOffset>
   [-Description <String>]
   [-DaysOfWeek <DayOfWeek[]>]
   [-ExpiryTime <DateTimeOffset>]
   -WeekInterval <Byte>
   [-TimeZone <String>]
   [-ForUpdateConfiguration]
   [-ResourceGroupName] <String>
   [-AutomationAccountName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzAutomationSchedule
   [-Name] <String>
   [-StartTime] <DateTimeOffset>
   [-Description <String>]
   [-DaysOfMonth <DaysOfMonth[]>]
   [-ExpiryTime <DateTimeOffset>]
   -MonthInterval <Byte>
   [-TimeZone <String>]
   [-ForUpdateConfiguration]
   [-ResourceGroupName] <String>
   [-AutomationAccountName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzAutomationSchedule
   [-Name] <String>
   [-StartTime] <DateTimeOffset>
   [-Description <String>]
   [-DayOfWeek <DayOfWeek>]
   [-DayOfWeekOccurrence <DayOfWeekOccurrence>]
   [-ExpiryTime <DateTimeOffset>]
   -MonthInterval <Byte>
   [-TimeZone <String>]
   [-ForUpdateConfiguration]
   [-ResourceGroupName] <String>
   [-AutomationAccountName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzAutomationSchedule
   [-Name] <String>
   [-StartTime] <DateTimeOffset>
   [-Description <String>]
   [-OneTime]
   [-TimeZone <String>]
   [-ForUpdateConfiguration]
   [-ResourceGroupName] <String>
   [-AutomationAccountName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzAutomationSchedule
   [-Name] <String>
   [-StartTime] <DateTimeOffset>
   [-Description <String>]
   [-ExpiryTime <DateTimeOffset>]
   -HourInterval <Byte>
   [-TimeZone <String>]
   [-ForUpdateConfiguration]
   [-ResourceGroupName] <String>
   [-AutomationAccountName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

New-AzAutomationSchedule Cmdlet 會在 Azure 自動化 中建立排程。

範例

範例 1:在當地時間建立一次性排程

$TimeZone = ([System.TimeZoneInfo]::Local).Id
New-AzAutomationSchedule -AutomationAccountName "Contoso17" -Name "Schedule01" -StartTime "23:00" -OneTime -ResourceGroupName "ResourceGroup01" -TimeZone $TimeZone

第一個命令會從系統取得時區標識符,並將它儲存在$TimeZone變數中。 第二個命令會建立排程,在指定時區的目前日期下午 11:00 執行一次。

範例 2:在另一個時區建立一次性排程

$TimeZone = "Europe/Paris"
New-AzAutomationSchedule -AutomationAccountName "Contoso17" -Name "Schedule01" -StartTime "23:00Z" -OneTime -ResourceGroupName "ResourceGroup01" -TimeZone $TimeZone

第一個命令會使用 值 Europe/Paris 初始化$TimeZone變數:第二個命令會在指定的時區的目前日期 23:00 UTC 上建立一次執行的排程。

注意:排程 StartTime 是藉由將 TimeZone Offset 新增至提供的 StartTime 來計算

範例 3:建立週期性排程

$StartTime = Get-Date "13:00:00"
$EndTime = $StartTime.AddYears(1)
New-AzAutomationSchedule -AutomationAccountName "Contoso17" -Name "Schedule02" -StartTime $StartTime -ExpiryTime $EndTime -DayInterval 1 -ResourceGroupName "ResourceGroup01"

第一個命令會使用 Get-Date Cmdlet 建立 date 對象,然後將物件儲存在 $StartDate 變數中。 指定未來至少五分鐘的時間。 第二個命令會使用 Get-Date Cmdlet 建立 date 對象,然後將物件儲存在$EndDate變數中。 命令會指定未來的時間。 最後一個命令會建立名為 Schedule02 的每日排程,以在儲存於$StartDate的時間開始,並在儲存於$EndDate的時間到期。

範例 4:建立每周週期性排程

$StartTime = (Get-Date "13:00:00").AddDays(1)
[System.DayOfWeek[]]$WeekDays = @([System.DayOfWeek]::Monday..[System.DayOfWeek]::Friday)
New-AzAutomationSchedule -AutomationAccountName "Contoso17" -Name "Schedule03" -StartTime $StartTime -WeekInterval 1 -DaysOfWeek $WeekDays -ResourceGroupName "ResourceGroup01"

第一個命令會使用 Get-Date Cmdlet 建立 date 對象,然後將物件儲存在 $StartDate 變數中。 第二個命令會建立包含星期一、星期二、星期三、星期四和星期五的星期幾陣列。 最後一個命令會建立名為 Schedule03 的每日排程,以每周 13:00 執行星期一至星期五。 排程永遠不會過期。

參數

-AutomationAccountName

指定這個 Cmdlet 建立排程的自動化帳戶名稱。

類型:String
Position:1
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-DayInterval

指定排程的間隔,以天為單位。 如果您未指定此參數,而且未指定 OneTime 參數,則預設值為一 (1)。

類型:Byte
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-DayOfWeek

指定每周排程的星期幾清單。

類型:Nullable<T>[DayOfWeek]
接受的值:Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DayOfWeekOccurrence

指定排程執行月份內的星期數。 psdx_paramvalues

  • 1
  • 2
  • 3
  • 4
  • -1
  • First
  • Second
  • Third
  • 第四個
  • LastDay
類型:DayOfWeekOccurrence
接受的值:First, Second, Third, Fourth, Last
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DaysOfMonth

指定每月排程月份的天數清單。

類型:DaysOfMonth[]
接受的值:One, Two, Three, Four, Five, Six, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth, Thirteenth, Fourteenth, Fifteenth, Sixteenth, Seventeenth, Eighteenth, Nineteenth, Twentieth, TwentyFirst, TwentySecond, TwentyThird, TwentyFourth, TwentyFifth, TwentySixth, TwentySeventh, TwentyEighth, TwentyNinth, Thirtieth, ThirtyFirst, LastDay
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DaysOfWeek

指定每周排程的星期幾清單。

類型:DayOfWeek[]
接受的值:Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DefaultProfile

用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶

類型:IAzureContextContainer
別名:AzContext, AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Description

指定排程的描述。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-ExpiryTime

指定排程的到期時間做為 DateTimeOffset 物件。 您可以指定可轉換成有效 DateTimeOffset 的字串。

類型:DateTimeOffset
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ForUpdateConfiguration

指出此排程物件將用於排程軟體更新組態

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-HourInterval

指定排程的間隔,以小時為單位。

類型:Byte
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-MonthInterval

指定排程的間隔,以月為單位。

類型:Byte
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Name

指定排程的名稱。

類型:String
Position:2
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-OneTime

指定 Cmdlet 會建立一次性排程。

類型:SwitchParameter
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-ResourceGroupName

指定此 Cmdlet 建立排程的資源群組名稱。

類型:String
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-StartTime

指定排程的開始時間做為 DateTimeOffset 物件。 您可以指定可轉換成有效 DateTimeOffset 的字串。 如果提供 TimeZone則會藉由新增 Input TimeZone 的 Offset 來計算 StartTime

類型:DateTimeOffset
Position:3
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-TimeZone

指定排程的時區。 此字串可以是 IANA 識別碼或 Windows 時區識別碼。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-WeekInterval

指定排程的間隔,以周為單位。

類型:Byte
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

輸入

String

DateTimeOffset

SwitchParameter

輸出

Schedule