Skip to content

Commit

Permalink
replaced powercfg with WMI
Browse files Browse the repository at this point in the history
  • Loading branch information
gwalkey authored Oct 30, 2020
1 parent 7d99551 commit 8a19d5e
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions Scripts/01_Server_Appliance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,25 @@ Param(
[string]$mypass
)

# Load Common Modules and .NET Assemblies
try
{
Import-Module ".\SQLTranscriptase.psm1" -ErrorAction Stop
}
catch
{
Throw('SQLTranscriptase.psm1 not found')
}

# Load Common Modules and .NET Assemblies
try
{
Import-Module ".\SQLTranscriptase.psm1" -ErrorAction Stop
}
catch
{
Throw('SQLTranscriptase.psm1 not found')
}

try
{
Import-Module ".\LoadSQLSmo.psm1"
}
catch
{
Throw('LoadSQLSmo.psm1 not found')
}

LoadSQLSMO

# Init
Expand Down Expand Up @@ -386,8 +395,16 @@ a42635e8-c082-4fbf-9bc1-6b12576771ab (Ultimate Performance)
#>
try
{
$mystring41 = [string] (& powercfg '/getactivescheme' 2>&1)

try
{
$PP = Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -CN c0sql1 -Filter "isActive='true'"
$mystring41 = $pp.elementName
}
catch
{
Write-host('Error getting Power Profile using WMI')
$mystring41=''
}
if (!($mystring41 -match "High" -or $mystring41 -match "Ulti"))
{
Write-output ("PowerPlan is *not optimal for SQL Server *")| out-file $fullFileName -Encoding ascii -Append
Expand Down

0 comments on commit 8a19d5e

Please sign in to comment.