@@ -62,7 +62,7 @@ function Get-AllAgentInfo {
62
62
}
63
63
' AgentServiceAccount' {
64
64
if (($Instance.VersionMajor -ge 14 ) -or $IsLinux -or $Instance.HostPlatform -eq ' Linux' ) {
65
- $Agent = @ ($Instance.Query (" SELECT status_desc, startup_type_desc FROM sys.dm_server_services" ) | Where-Object servicename -Like ' *Agent*' ).ForEach {
65
+ $Agent = @ ($Instance.Query (" SELECT status_desc, startup_type_desc, servicename FROM sys.dm_server_services" ) | Where-Object servicename -Like ' *Agent*' ).ForEach {
66
66
[PSCustomObject ]@ {
67
67
State = $PSItem.status_desc
68
68
StartMode = $PSItem.startup_type_desc
@@ -163,10 +163,10 @@ function Get-AllAgentInfo {
163
163
164
164
$JobsFailed = ($Instance.JobServer.Jobs | Where-Object { $_.IsEnabled -and ($_.LastRunDate -gt $startdate ) }).ForEach {
165
165
[PSCustomObject ]@ {
166
- InstanceName = $Instance.Name
167
- JobName = $PSItem.Name
168
- ExpectedOutcome = $ConfigValues.FailedJob
169
- LastRunOutcome = $PSItem.LastRunOutcome
166
+ InstanceName = $Instance.Name
167
+ JobName = $PSItem.Name
168
+ ExpectedOutcome = $ConfigValues.FailedJob
169
+ LastRunOutcome = $PSItem.LastRunOutcome
170
170
}
171
171
}
172
172
}
@@ -180,10 +180,10 @@ function Get-AllAgentInfo {
180
180
181
181
$JobOwner = $Instance.JobServer.Jobs.ForEach {
182
182
[PSCustomObject ]@ {
183
- InstanceName = $Instance.Name
184
- JobName = $PSItem.Name
185
- ExpectedJobOwnerName = $ConfigValues.TargetJobOwner # $PSItem
186
- ActualJobOwnerName = $PSItem.OwnerLoginName
183
+ InstanceName = $Instance.Name
184
+ JobName = $PSItem.Name
185
+ ExpectedJobOwnerName = $ConfigValues.TargetJobOwner # $PSItem
186
+ ActualJobOwnerName = $PSItem.OwnerLoginName
187
187
}
188
188
}
189
189
}
@@ -197,10 +197,10 @@ function Get-AllAgentInfo {
197
197
198
198
$InvalidJobOwner = $Instance.JobServer.Jobs.ForEach {
199
199
[PSCustomObject ]@ {
200
- InstanceName = $Instance.Name
201
- JobName = $PSItem.Name
202
- ExpectedJobOwnerName = $ConfigValues.InvalidJobOwner
203
- ActualJobOwnerName = $PSItem.OwnerLoginName
200
+ InstanceName = $Instance.Name
201
+ JobName = $PSItem.Name
202
+ ExpectedJobOwnerName = $ConfigValues.InvalidJobOwner
203
+ ActualJobOwnerName = $PSItem.OwnerLoginName
204
204
}
205
205
}
206
206
@@ -303,13 +303,13 @@ function Get-AllAgentInfo {
303
303
304
304
$LongRunningJobs = $ ($runningjobs | Where-Object { $_.AvgSec -ne 0 }).ForEach {
305
305
[PSCustomObject ]@ {
306
- InstanceName = $Instance.Name
307
- JobName = $PSItem.JobName
308
- RunningSeconds = $PSItem.RunningSeconds
309
- Average = $PSItem.AvgSec
310
- Diff = $PSItem.Diff
311
- ExpectedLongRunningJobPercentage = $ConfigValues.LongRunningJob
312
- ActualLongRunningJobPercentage = [math ]::Round($PSItem.Diff / $PSItem.AvgSec * 100 )
306
+ InstanceName = $Instance.Name
307
+ JobName = $PSItem.JobName
308
+ RunningSeconds = $PSItem.RunningSeconds
309
+ Average = $PSItem.AvgSec
310
+ Diff = $PSItem.Diff
311
+ ExpectedLongRunningJobPercentage = $ConfigValues.LongRunningJob
312
+ ActualLongRunningJobPercentage = [math ]::Round($PSItem.Diff / $PSItem.AvgSec * 100 )
313
313
}
314
314
}
315
315
}
@@ -367,12 +367,12 @@ function Get-AllAgentInfo {
367
367
368
368
$LastJobRuns = $ ($lastagentjobruns | Where-Object { $_.AvgSec -ne 0 }).ForEach {
369
369
[PSCustomObject ]@ {
370
- InstanceName = $Instance.Name
371
- JobName = $PSItem.JobName
372
- Duration = $PSItem.Duration
373
- Average = $PSItem.AvgSec
374
- ExpectedRunningJobPercentage = $ConfigValues.LastJobRuns
375
- ActualRunningJobPercentage = [math ]::Round($PSItem.Diff / $PSItem.AvgSec * 100 )
370
+ InstanceName = $Instance.Name
371
+ JobName = $PSItem.JobName
372
+ Duration = $PSItem.Duration
373
+ Average = $PSItem.AvgSec
374
+ ExpectedRunningJobPercentage = $ConfigValues.LastJobRuns
375
+ ActualRunningJobPercentage = [math ]::Round($PSItem.Diff / $PSItem.AvgSec * 100 )
376
376
}
377
377
}
378
378
}
0 commit comments