The Win32_ScheduledJobâWMI classârepresents a job created with the AT command. ®
Methods
Win32_ScheduledJob has 2 methods:
Method | Description |
---|---|
Create | Class method that submits a job to the operating system for execution at a specified future time and date. |
Delete | Class method that deletes a scheduled job. |
Learn more about Invoke-CimMethod
and how to invoke commands. Click any of the methods listed above to learn more about their purpose, parameters, and return value.
Properties
Win32_ScheduledJob returns 19 properties:
'Caption','Command','DaysOfMonth','DaysOfWeek','Description','ElapsedTime',
'InstallDate','InteractWithDesktop','JobId','JobStatus','Name','Notify','Owner','Priority',
'RunRepeatedly','StartTime','Status','TimeSubmitted','UntilTime'
Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:
Get-CimInstance -ClassName Win32_ScheduledJob -Property *
Most WMI classes return one or more instances.
When
Get-CimInstance
returns no result, then apparently no instances of class Win32_ScheduledJob exist. This is normal behavior.Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).
Caption
A short textual description of the object.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Caption
Command
Name of the command, batch program, or binary file (and command-line arguments) that the schedule service uses to invoke the job.
Example: “defrag /q/f”
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Command
DaysOfMonth
Days of the month when the job is scheduled to run. If a job is scheduled to run on multiple days of the month, these values can be joined in a logical OR. For example, if a job is to run on the 1st and 16th of each month, the value of the DaysOfMonth property would be 1 OR 32768.
DaysOfMonth returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$DaysOfMonth_map = @{
1 = '1'
2 = '2'
4 = '3'
8 = '4'
16 = '5'
32 = '6'
64 = '7'
128 = '8'
256 = '9'
512 = '10'
1024 = '11'
2048 = '12'
4096 = '13'
8192 = '14'
16384 = '15'
32768 = '16'
65536 = '17'
131072 = '18'
262144 = '19'
524288 = '20'
1048576 = '21'
2097152 = '22'
4194304 = '23'
8388608 = '24'
16777216 = '25'
33554432 = '26'
67108864 = '27'
134217728 = '28'
268435456 = '29'
536870912 = '30'
1073741824 = '31'
}
Use a switch statement
switch([int]$value)
{
1 {'1'}
2 {'2'}
4 {'3'}
8 {'4'}
16 {'5'}
32 {'6'}
64 {'7'}
128 {'8'}
256 {'9'}
512 {'10'}
1024 {'11'}
2048 {'12'}
4096 {'13'}
8192 {'14'}
16384 {'15'}
32768 {'16'}
65536 {'17'}
131072 {'18'}
262144 {'19'}
524288 {'20'}
1048576 {'21'}
2097152 {'22'}
4194304 {'23'}
8388608 {'24'}
16777216 {'25'}
33554432 {'26'}
67108864 {'27'}
134217728 {'28'}
268435456 {'29'}
536870912 {'30'}
1073741824 {'31'}
default {"$value"}
}
Use Enum structure
Enum EnumDaysOfMonth
{
_1 = 1
_2 = 2
_3 = 4
_4 = 8
_5 = 16
_6 = 32
_7 = 64
_8 = 128
_9 = 256
_10 = 512
_11 = 1024
_12 = 2048
_13 = 4096
_14 = 8192
_15 = 16384
_16 = 32768
_17 = 65536
_18 = 131072
_19 = 262144
_20 = 524288
_21 = 1048576
_22 = 2097152
_23 = 4194304
_24 = 8388608
_25 = 16777216
_26 = 33554432
_27 = 67108864
_28 = 134217728
_29 = 268435456
_30 = 536870912
_31 = 1073741824
}
Examples
Use $DaysOfMonth_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "DaysOfMonth" to friendly text
Note: to use other properties than "DaysOfMonth", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "DaysOfMonth"
# to translate other properties, use their translation table instead
$DaysOfMonth_map = @{
1 = '1'
2 = '2'
4 = '3'
8 = '4'
16 = '5'
32 = '6'
64 = '7'
128 = '8'
256 = '9'
512 = '10'
1024 = '11'
2048 = '12'
4096 = '13'
8192 = '14'
16384 = '15'
32768 = '16'
65536 = '17'
131072 = '18'
262144 = '19'
524288 = '20'
1048576 = '21'
2097152 = '22'
4194304 = '23'
8388608 = '24'
16777216 = '25'
33554432 = '26'
67108864 = '27'
134217728 = '28'
268435456 = '29'
536870912 = '30'
1073741824 = '31'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "DaysOfMonth", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$DaysOfMonth = @{
Name = 'DaysOfMonth'
Expression = {
# property is an array, so process all values
$value = $_.DaysOfMonth
$DaysOfMonth_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "DaysOfMonth". The latter
# is defined by the hashtable in $DaysOfMonth:
Get-CimInstance -Class Win32_ScheduledJob | Select-Object -Property Caption, $DaysOfMonth
# ...or dump content of property DaysOfMonth:
$friendlyValues = Get-CimInstance -Class Win32_ScheduledJob |
Select-Object -Property $DaysOfMonth |
Select-Object -ExpandProperty DaysOfMonth
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DaysOfMonth_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_ScheduledJob" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_ScheduledJob", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_ScheduledJob"
# to translate other properties, use their translation table instead
$DaysOfMonth_map = @{
1 = '1'
2 = '2'
4 = '3'
8 = '4'
16 = '5'
32 = '6'
64 = '7'
128 = '8'
256 = '9'
512 = '10'
1024 = '11'
2048 = '12'
4096 = '13'
8192 = '14'
16384 = '15'
32768 = '16'
65536 = '17'
131072 = '18'
262144 = '19'
524288 = '20'
1048576 = '21'
2097152 = '22'
4194304 = '23'
8388608 = '24'
16777216 = '25'
33554432 = '26'
67108864 = '27'
134217728 = '28'
268435456 = '29'
536870912 = '30'
1073741824 = '31'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_ScheduledJob | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.DaysOfMonth
# translate raw value to friendly text:
$friendlyName = $DaysOfMonth_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "DaysOfMonth" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "DaysOfMonth", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "DaysOfMonth", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$DaysOfMonth = @{
Name = 'DaysOfMonth'
Expression = {
# property is an array, so process all values
$value = $_.DaysOfMonth
switch([int]$value)
{
1 {'1'}
2 {'2'}
4 {'3'}
8 {'4'}
16 {'5'}
32 {'6'}
64 {'7'}
128 {'8'}
256 {'9'}
512 {'10'}
1024 {'11'}
2048 {'12'}
4096 {'13'}
8192 {'14'}
16384 {'15'}
32768 {'16'}
65536 {'17'}
131072 {'18'}
262144 {'19'}
524288 {'20'}
1048576 {'21'}
2097152 {'22'}
4194304 {'23'}
8388608 {'24'}
16777216 {'25'}
33554432 {'26'}
67108864 {'27'}
134217728 {'28'}
268435456 {'29'}
536870912 {'30'}
1073741824 {'31'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_ScheduledJob |
# ...and output properties "Caption" and "DaysOfMonth". The latter is defined
# by the hashtable in $DaysOfMonth:
Select-Object -Property Caption, $DaysOfMonth
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_ScheduledJob", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumDaysOfMonth
{
_1 = 1
_2 = 2
_3 = 4
_4 = 8
_5 = 16
_6 = 32
_7 = 64
_8 = 128
_9 = 256
_10 = 512
_11 = 1024
_12 = 2048
_13 = 4096
_14 = 8192
_15 = 16384
_16 = 32768
_17 = 65536
_18 = 131072
_19 = 262144
_20 = 524288
_21 = 1048576
_22 = 2097152
_23 = 4194304
_24 = 8388608
_25 = 16777216
_26 = 33554432
_27 = 67108864
_28 = 134217728
_29 = 268435456
_30 = 536870912
_31 = 1073741824
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_ScheduledJob | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.DaysOfMonth
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **DaysOfMonth**
[EnumDaysOfMonth]$rawValue
# get a comma-separated string:
[EnumDaysOfMonth]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumDaysOfMonth]
#endregion
Enums must cover all possible values. If DaysOfMonth returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
DaysOfWeek
Days of the week when a job is scheduled to run. If a job is scheduled to run on multiple days of the week, the values can be joined in a logical OR. For example, if a job is scheduled to run on Mondays, Wednesdays, and Fridays the value of the DaysOfWeek property would be 1 OR 4 OR 16.
DaysOfWeek returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$DaysOfWeek_map = @{
1 = 'Monday'
2 = 'Tuesday'
4 = 'Wednesday'
8 = 'Thursday'
16 = 'Friday'
32 = 'Saturday'
64 = 'Sunday'
}
Use a switch statement
switch([int]$value)
{
1 {'Monday'}
2 {'Tuesday'}
4 {'Wednesday'}
8 {'Thursday'}
16 {'Friday'}
32 {'Saturday'}
64 {'Sunday'}
default {"$value"}
}
Use Enum structure
Enum EnumDaysOfWeek
{
Monday = 1
Tuesday = 2
Wednesday = 4
Thursday = 8
Friday = 16
Saturday = 32
Sunday = 64
}
Examples
Use $DaysOfWeek_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "DaysOfWeek" to friendly text
Note: to use other properties than "DaysOfWeek", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "DaysOfWeek"
# to translate other properties, use their translation table instead
$DaysOfWeek_map = @{
1 = 'Monday'
2 = 'Tuesday'
4 = 'Wednesday'
8 = 'Thursday'
16 = 'Friday'
32 = 'Saturday'
64 = 'Sunday'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "DaysOfWeek", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$DaysOfWeek = @{
Name = 'DaysOfWeek'
Expression = {
# property is an array, so process all values
$value = $_.DaysOfWeek
$DaysOfWeek_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "DaysOfWeek". The latter
# is defined by the hashtable in $DaysOfWeek:
Get-CimInstance -Class Win32_ScheduledJob | Select-Object -Property Caption, $DaysOfWeek
# ...or dump content of property DaysOfWeek:
$friendlyValues = Get-CimInstance -Class Win32_ScheduledJob |
Select-Object -Property $DaysOfWeek |
Select-Object -ExpandProperty DaysOfWeek
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DaysOfWeek_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_ScheduledJob" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_ScheduledJob", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_ScheduledJob"
# to translate other properties, use their translation table instead
$DaysOfWeek_map = @{
1 = 'Monday'
2 = 'Tuesday'
4 = 'Wednesday'
8 = 'Thursday'
16 = 'Friday'
32 = 'Saturday'
64 = 'Sunday'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_ScheduledJob | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.DaysOfWeek
# translate raw value to friendly text:
$friendlyName = $DaysOfWeek_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "DaysOfWeek" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "DaysOfWeek", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "DaysOfWeek", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$DaysOfWeek = @{
Name = 'DaysOfWeek'
Expression = {
# property is an array, so process all values
$value = $_.DaysOfWeek
switch([int]$value)
{
1 {'Monday'}
2 {'Tuesday'}
4 {'Wednesday'}
8 {'Thursday'}
16 {'Friday'}
32 {'Saturday'}
64 {'Sunday'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_ScheduledJob |
# ...and output properties "Caption" and "DaysOfWeek". The latter is defined
# by the hashtable in $DaysOfWeek:
Select-Object -Property Caption, $DaysOfWeek
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_ScheduledJob", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumDaysOfWeek
{
Monday = 1
Tuesday = 2
Wednesday = 4
Thursday = 8
Friday = 16
Saturday = 32
Sunday = 64
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_ScheduledJob | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.DaysOfWeek
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **DaysOfWeek**
[EnumDaysOfWeek]$rawValue
# get a comma-separated string:
[EnumDaysOfWeek]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumDaysOfWeek]
#endregion
Enums must cover all possible values. If DaysOfWeek returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
Description
A textual description of the object.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Description
ElapsedTime
Length of time the job has been executing.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, ElapsedTime
InstallDate
Indicates when the object was installed. Lack of a value does not indicate that the object is not installed.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, InstallDate
InteractWithDesktop
Specified job is interactive, which means that a user can give input to a scheduled job while it is executing.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, InteractWithDesktop
JobId
Identifying number of the job. It is used by methods as a handle to one job being scheduled on this computer.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId
JobStatus
Status of execution the last time this job was scheduled to run.
Success (“Success”)
Failure (“Failure”)
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, JobStatus
Name
Label by which the object is known. When subclassed, this property can be overridden to be a key property.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Name
Notify
User is notified upon job completion or failure.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Notify
Owner
User who submitted the job.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Owner
Priority
Importance of a job’s execution.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Priority
RunRepeatedly
Scheduled job runs repeatedly on the days that the job is scheduled. If False, then the job is run one time.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, RunRepeatedly
StartTime
UTC time to run the job, in the form of “YYYYMMDDHHMMSS.MMMMMM(+-)OOO”, where “YYYYMMDD” must be replaced by “****”. The replacement is necessary because the scheduling service only allows jobs to be configured to run one time, or run on a day of the month or week. A job cannot be run on a specific date.
The “(+-)OOO” section of the StartTime property value is the current bias for local time translation. The bias is the difference between the UTC time and local time. To calculate the bias for your time zone, multiply the number of hours that your time zone is ahead or behind Greenwich Mean Time (GMT) by 60 (use a positive number for the number of hours if your time zone is ahead of GMT and a negative number if your time zone is behind GMT). Add an additional 60 to your calculation if your time zone is using daylight savings time. For example, the Pacific Standard Time zone is eight hours behind GMT, therefore the bias is equals to -420 (-8 * 60 + 60) when daylight savings time is in use and -480 (-8 * 60) when daylight savings time is not in use. You can also determine the value of the bias by querying the bias property of the Win32_TimeZone class.
For example: “****123000.000000-420” specifies 14.30 (2:30 P.M.) PST with daylight savings time in effect.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, StartTime
Status
Current status of an object. Various operational and nonoperational statuses can be defined. Available values:
$values = 'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, Status
TimeSubmitted
Time that the job was submitted.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, TimeSubmitted
UntilTime
Time at which the job is invalid or should be stopped.
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property JobId, UntilTime
Examples
List all instances of Win32_ScheduledJob
Get-CimInstance -ClassName Win32_ScheduledJob
Learn more about Get-CimInstance
and the deprecated Get-WmiObject
.
View all properties
Get-CimInstance -ClassName Win32_ScheduledJob -Property *
View key properties only
Get-CimInstance -ClassName Win32_ScheduledJob -KeyOnly
Selecting Properties
To select only some properties, pipe the results to Select-Object -Property a,b,c
with a comma-separated list of the properties you require. Wildcards are permitted.
Get-CimInstance
always returns all properties but only retrieves the ones that you specify. All other properties are empty but still present. That’s why you need to pipe the results into Select-Object
if you want to limit the visible properties, i.e. for reporting.
Selecting Properties
The code below lists all available properties. Remove the ones you do not need:
$properties = 'Caption',
'Command',
'DaysOfMonth',
'DaysOfWeek',
'Description',
'ElapsedTime',
'InstallDate',
'InteractWithDesktop',
'JobId',
'JobStatus',
'Name',
'Notify',
'Owner',
'Priority',
'RunRepeatedly',
'StartTime',
'Status',
'TimeSubmitted',
'UntilTime'
Get-CimInstance -ClassName Win32_ScheduledJob | Select-Object -Property $properties
Limiting Network Bandwidth
If you work remotely, it makes sense to limit network bandwidth by filtering the properties on the server side, too:
Get-CimInstance -Class Win32_ScheduledJob -Property $property |
Select-Object -Property $property
Selecting Instances
To select some instances, use Get-CimInstance and a WMI Query. The wildcard character in WMI Queries is % (and not “*”).
The parameter -Filter runs a simple query.
Listing all instances where the property Caption starts with “A”
Get-CimInstance -Class Win32_ScheduledJob -Filter 'Caption LIKE "a%"'
Using a WQL Query
The parameter -Query uses a query similar to SQL and combines the parameters -Filter and -Property. This returns all instances where the property Caption starts with “A”, and returns the properties specified:
Get-CimInstance -Query "SELECT Caption, Description, TimeSubmitted, InstallDate FROM Win32_ScheduledJob WHERE Caption LIKE 'a%'"
Any property you did not specify is still present but empty. You might need to use
Select-Object
to remove all unwanted properties:Get-CimInstance -Query "SELECT Caption, Description, TimeSubmitted, InstallDate FROM Win32_ScheduledJob WHERE Caption LIKE 'a%'" | Select-Object -Property Caption, Description, TimeSubmitted, InstallDate
Accessing Remote Computers
To access remote systems, you need to have proper permissions. User the parameter -ComputerName to access one or more remote systems.
Authenticating as Current User
# one or more computer names or IP addresses:
$list = 'server1', 'server2'
# authenticate with your current identity:
$result = Get-CimInstance -ClassName Win32_ScheduledJob -ComputerName $list
$result
Authenticating as Different User
Use a CIMSession object to authenticate with a new identity:
# one or more computer names or IP addresses:
$list = 'server1', 'server2'
# authenticate with a different identity:
$cred = Get-Credential -Message 'Authenticate to retrieve WMI information:'
$session = New-CimSession -ComputerName $list -Credential $cred
$result = Get-CimInstance Win32_ScheduledJob -CimSession $session
# remove the session after use (if you do not plan to re-use it later)
Remove-CimSession -CimSession $session
$result
Learn more about accessing remote computers.
Requirements
To use Win32_ScheduledJob, the following requirements apply:
PowerShell
Get-CimInstance
was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.
If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.
Operating System
Win32_ScheduledJob was introduced on clients with Windows Vista and on servers with Windows Server 2008.
Namespace
Win32_ScheduledJob lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance
.
Implementation
Win32_ScheduledJob is implemented in CIMWin32.dll and defined in CIMWin32.mof. Both files are located in the folder C:\Windows\system32\wbem
:
explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\CIMWin32.mof