-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-job-old.ps1
66 lines (52 loc) · 1.62 KB
/
create-job-old.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#Requires -Version 2
<#
.SYNOPSIS
Create Job
Create job in Windows Task Scheduler for script Get System Report.
Script supports run locally.
.DESCRIPTION
Create Job
Create job in Windows Task Scheduler for script Get System Report.
FEATURES
* create new job;
KNOWNPROBLEMS
* (none);
SYSTEMREQUIREMENTS
* Windows Pro, or
* Windows Enterprise, or
* Windows Server
* Windows PowerShell v3+
Developed and tested on
* Windows Server 2012,
* Windows 10, Windows Server 2016.
.OUTPUTS
.
.EXAMPLE
C:\> get-systemreport.ps1
.LINK
http://www.michalzobec.cz/
.NOTES
Create Job
(c) 2016-2017 Michal Zobec, ZOBEC Consulting. All Rights Reserved.
web: www.michalzobec.cz, mail: obchod@zobec.net
License: Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) https://creativecommons.org/licenses/by-sa/4.0/
.HISTORY
version 17.08.20.1;
* init version;
version 17.08.28.1;
* verified on PSv2, minimal requirements is PSv3;
version 17.10.17.1;
* changed used account to SYSTEM;
.TODO
* (none);
#>
$DateTime = Get-Date -Format "dd.MM.yyyy HH:mm:ss"
$Revision = Get-Date -Format "yy.MM.dd-HH.mm"
$Scriptfile = (split-path $myinvocation.mycommand.path) + "\get-systemreport.ps1"
$TaskName = "Get System Report (inst $Revision)"
if ($Task -ne $null)
{
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$False
}
# write-host "schtasks /Create /SC daily /TN $TaskName /ST 6:00 /TR "powershell.exe -ExecutionPolicy Bypass -File `"$Scriptfile`"" /RU $env:USERDOMAIN\$env:USERNAME"
schtasks /Create /SC daily /TN "$TaskName" /ST 06:00 /TR "powershell.exe -ExecutionPolicy Bypass -File `"$Scriptfile`"" /RU $env:USERDOMAIN\$env:USERNAME