-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathGet-MaxDop.ps1
41 lines (37 loc) · 1.4 KB
/
Get-MaxDop.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
Param(
[Parameter(Mandatory=$True)]
[string]$sqlserver
)
$sqlquery = "DECLARE @sched_c int, @node_c int, @maxdop int
SELECT @sched_c = COUNT(scheduler_id), @node_c = COUNT(DISTINCT parent_node_id) FROM sys.dm_os_schedulers WHERE is_online = 1 AND scheduler_id < 255 AND parent_node_id < 64;
SELECT @maxdop = CAST ([value] as INT) FROM sys.configurations WHERE name = 'max degree of parallelism';
IF (@sched_c <= 8 AND @node_C = 1 AND @maxdop BETWEEN 1 AND @sched_c)
BEGIN
SELECT @maxdop as DOP, 'PASS' as Result
END
ELSE IF (@sched_c > 8 AND @node_C = 1 AND @maxdop BETWEEN 1 AND 8)
BEGIN
SELECT @maxdop as DOP, 'PASS' as Result
END
ELSE IF (@sched_c <= 8 AND @node_C > 1 AND @maxdop BETWEEN 1 AND @node_C)
BEGIN
SELECT @maxdop as DOP, 'PASS' as Result
END
ELSE IF (@sched_c > 8 AND @node_C > 1 AND @maxdop BETWEEN 1 AND 8)
BEGIN
SELECT @maxdop as DOP, 'PASS' as Result
END
ELSE
BEGIN
SELECT @maxdop as DOP, 'FAIL' as Result
END
"
$MAXDOP = Invoke-Sqlcmd -ServerInstance $sqlserver -Query $sqlquery
if ($MAXDOP.Result -eq "PASS")
{
Write-Host "[INFO] Max Degree of Parallelism value of" $MAXDOP.DOP "has been configured as per best practices described in KB2806535" -ForegroundColor Green
}
else
{
Write-Host "[WARN] Max Degree of Parallelism value of" $MAXDOP.DOP "has not been configured as per best practices described in KB2806535" -ForegroundColor Red
}