@@ -49,7 +49,7 @@ function OpCon_Login
49
49
Param (
50
50
[Parameter (Mandatory = $true )] [string ]$url
51
51
, [Parameter (Mandatory = $true )] [string ]$user
52
- , [Parameter ( Mandatory = $true )] [ string ]$password
52
+ , [string ] $password
53
53
, [string ] $appname
54
54
)
55
55
@@ -66,6 +66,18 @@ function OpCon_Login
66
66
}
67
67
}
68
68
}
69
+ elseif ($user -like " Win*Auth*" )
70
+ {
71
+ try
72
+ {
73
+ return Invoke-Restmethod - Method POST - Uri ($url + " /api/tokens" ) - ContentType " application/json" - UseDefaultCredentials
74
+ }
75
+ catch [Exception ]
76
+ {
77
+ write-host $_
78
+ write-host $_.Exception.Message
79
+ }
80
+ }
69
81
else
70
82
{
71
83
$body = @ {
@@ -90,6 +102,11 @@ function OpCon_Login
90
102
}
91
103
New-Alias " opc-login" OpCon_GetLogin
92
104
105
+ function OpCon_Errors ($action )
106
+ {
107
+ $ErrorActionPreference = $action
108
+ }
109
+
93
110
# Delete token from database
94
111
function OpCon_DeleteAPIToken
95
112
{
@@ -168,7 +185,7 @@ function OpCon_CreateGlobalProperty
168
185
, [Parameter (Mandatory = $true )] [string ]$token
169
186
, [Parameter (Mandatory = $true )] [string ]$name
170
187
, [Parameter (Mandatory = $true )] [string ]$value
171
- , [string ] $encrypt
188
+ , [string ] $encrypt = $false
172
189
)
173
190
174
191
# Get property information
@@ -180,7 +197,7 @@ function OpCon_CreateGlobalProperty
180
197
181
198
try
182
199
{
183
- return nvoke - Restmethod - Method POST - Uri ($url + " /api/globalproperties" ) - Headers @ {" authorization" = $token } - Body ($body | ConvertTo-Json ) - ContentType " application/json"
200
+ return Invoke -Restmethod - Method POST - Uri ($url + " /api/globalproperties" ) - Headers @ {" authorization" = $token } - Body ($body | ConvertTo-Json ) - ContentType " application/json"
184
201
}
185
202
catch [Exception ]
186
203
{
@@ -990,7 +1007,7 @@ function OpCon_GetDailyJob($url,$token,$sname,$jname,$date,$id)
990
1007
New-Alias " opc-getdailyjob" OpCon_GetDailyJob
991
1008
992
1009
# Sends a job action to a job
993
- function OpCon_JobAction ($url , $token , $sname , $jname , $date , $action , $reason )
1010
+ function OpCon_JobAction ($url , $token , $sname , $jname , $jobId , $ date, $action , $reason )
994
1011
{
995
1012
if ($action )
996
1013
{
@@ -1014,23 +1031,27 @@ function OpCon_JobAction($url,$token,$sname,$jname,$date,$action,$reason)
1014
1031
}
1015
1032
}
1016
1033
1017
- if ($jname -and $sname )
1034
+ if ($jname -and $sname -or $jobId )
1018
1035
{
1019
1036
if (! $date )
1037
+ { $date = Get-Date - Format " yyyy/MM/dd" }
1038
+
1039
+ $jobsArray = @ ()
1040
+ if (! $jobId )
1020
1041
{
1021
- $date = Get-Date - Format " yyyy/MM/dd"
1022
- }
1023
- $job = OpCon_GetDailyJob - url $url - token $token - sname " $sname " - jname " $jname " - date $date
1042
+ $job = OpCon_GetDailyJob - url $url - token $token - sname $sname - jname $jname - date $date
1024
1043
1025
- $counter = 0
1026
- $job | ForEach-Object { $counter ++ }
1027
- If ($counter -ne 1 )
1028
- {
1029
- Write-Host " Too many results for job!`r`n "
1044
+ $counter = 0
1045
+ $job | ForEach-Object { $counter ++ }
1046
+ If ($counter -ne 1 )
1047
+ {
1048
+ Write-Host " Too many results for job!`r`n "
1049
+ }
1050
+ else
1051
+ { $jobsArray += @ { id = $job [0 ].id; } }
1030
1052
}
1031
-
1032
- $jobsArray = @ ()
1033
- $jobsArray += @ { id = $job [0 ].id; }
1053
+ else
1054
+ { $jobsArray += @ { id = $jobId } }
1034
1055
1035
1056
$body = @ {
1036
1057
" action" = $action ;
0 commit comments