Setting Schedule-Variables
Setting Schedule-Variables
Sets the value of objects of the type "Schedule". The value can be specified in different formats.
In general:
Set-EmdbSchedule -Schedule $MySchedule -Value <value>
Set-EmdbSchedule -Item <Object> -Value <value>
For setting values via Set-EmdbSchedule, a hashtable can also be specified for Value, in addition to the DSM database value. In addition, strings that can be "translated" into a hashtable are also supported. In general:
Set-EmdbSchedule -Item <Object> -Value ($MySchedule.ToHashtable())
Set-EmdbSchedule -Item <Object> -Value ($MySchedule.ToString())
General hashtable format:
@{ <indication of day of week or month> = @{ <indication of hour or day> = <activation>; ...} ... }
@{ week = @{ <indication for day of week> = @{ <indication for hour> = <activation>; ...} ... }; year = @{ <indication for month> = @{ <indication for day> = <activation>; ... } ... } }
Additional optional hashtable entries: @{ language = "<language>"; activationChars = "YNyn"; ... }
Designations for days of the week and months can also be specified in another language, activations can be specified with alternative characters.
Hashtables can also be specified in "TextForm":
"<indication to day of week or month>:<indication to hour or day>=<activation>; ..."
Format |
Option |
In Hashtable |
Text form |
<indication of day of the week> |
Single day of the week in long form (Monday) or short form (Mon, or Mo) |
@{ Monday = … }, @{ Mon = … }, @{ "Mo" = … } (Quotation marks are optional) |
"Monday: …", "Mon: …", "Mo: …" |
|
List of weekdays |
@{ ("Mon","Tue") = … }, @{ "Mon,Tue" = … } (Quotation marks are required) |
"Mon, Tue: …" |
|
Range of weekdays |
@{ "Mon - Wed" = … } |
"Mon - Wed: …" |
<Indication of month> |
Single month in long or short form |
@{ January = … }, @{ Jan = … } |
"January: …", "Jan: …" |
|
List of months |
@{ ("Jan","Feb") = … }, @{ "Jan,Feb" = … } |
"Jan, Feb: …" |
|
Range of months |
@{ "Jan - Mar" = … } |
"Jan - Mar: …" |
<Statement of weekday or month> |
Specify a date/time value. If a value is not specified below "week" or "year", it applies to both. |
@{ ([DateTime]::Now) = … } |
"2023-04-19 19:00: …" |
|
List of date/time values |
@{ ([DateTime]::Now, [DateTime]::Now.AddDays(2)) = … }, @{ "2023-03-05 18:00, 2023-03-06 19:00" = … } |
"2023-04-19 18:00, 2023-04-22 19:00: …" |
|
Range of date/time values |
@{ "2023-03-05 18:00 - 2023-03-06 19:00" = … } |
"2023-03-05 18:00 - 2023-03-06 19:00: …" |
<specify by day>, <specify by hour>. |
Single value |
@{ 5 = … } |
"… : 5 = …" |
|
List of values |
@{ (5, 7, 9) = … }, @{ "5,7,9" = … } |
"… : 5,7,9 = …" |
|
Range of values |
@{ (5..9) = … }, @{ "5-9" = … } |
"… : 5-9 = …" |
<Activation> |
Active |
@{ … = "Active" }, @{ … = "Y" } * |
"… : … = Active; …", "… : … = Y"; |
|
Inactive |
@{ … = "Inactive" }, @{ … = "N" } |
"… : … = Inactive; …", "… : … = N"; |
|
Active, user decides |
@{ … = "Active, UserDecides" }, @{ … = "y" } |
"… : … = Active, UserDecides; …", "… : … = y; …" |
|
Inactive, user decides |
@{ … = "Inactive, UserDecides" }, @{ … = "n" } |
"… : … = Inactive, UserDecides; …", "… : … = n; …" |
Examples:
Hint: The execution of these examples requires a connected PowerShell drive. |
In the first example, the maintenance window for the computer "WIN10-01" is set to Active all day on Mondays and Tuesdays:
$MyComputer = Get-EmdbComputer "WIN10-01" -Recurse $Value = "Mon,Tue:0-23 = Active" Set-EmdbSchedule -Item $MyComputer -Value $Value |
The maintenance window can also be specified as a hashtable, whereby it should be noted that the day/hour information is separated from the activation type with "=" in the value of the hashtable:
$MyComputer = Get-EmdbComputer "WIN10-01" -Recurse $Value = @{ "Jan - Mar" = "1-31=Active"} Set-EmdbSchedule -Item $MyComputer -Value $Value |