-
Notifications
You must be signed in to change notification settings - Fork 13
/
Win32_ScheduledJob.ps1
24 lines (22 loc) · 1.04 KB
/
Win32_ScheduledJob.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$arguments = @{
Command = 'notepad.exe' # replace 'someText' with meaningful text
DaysOfMonth = [UInt32](12345) # replace 12345 with a meaningful value
DaysOfWeek = [UInt32](12345) # replace 12345 with a meaningful value
InteractWithDesktop = [Boolean](12345) # replace 12345 with a meaningful value
RunRepeatedly = [Boolean](12345) # replace 12345 with a meaningful value
StartTime = [DateTime](12345) # replace 12345 with a meaningful value
}
Invoke-CimMethod -ClassName Win32_ScheduledJob -Namespace Root/CIMV2 -MethodName Create -Arguments $arguments |
Add-Member -MemberType ScriptProperty -Name ReturnValueFriendly -Passthru -Value {
switch ([int]$this.ReturnValue)
{
0 {'Successful completion'}
1 {'Not supported'}
2 {'Access denied'}
8 {'Unknown failure'}
9 {'Path not found'}
21 {'Invalid parameter'}
22 {'Service not started'}
default {'Unknown Error '}
}
}