MysticFoxDE / WINDOWS-OPTIMIZATIONS

SKRIPTS FOR WINDOWS DESUBOPTIMIZATION
606 stars 54 forks source link

Invalid check on $HYPERVSTATE #22

Open mbk1969 opened 9 months ago

mbk1969 commented 9 months ago

Hello. I ran your script and noticed messages in log:

Check Hyper-V status Hyper-V is disabled. ... Due to the installed Hyper-V role, the optimization of the PACKET COALESCING FILTER ON WINDOWS TCP-STACK is skipped. Due to the installed Hyper-V role, the optimization of the RECEIVE SIDE SCALING on Windows TCP-Stack is skipped.

Then I went into ps1-file itself to see the commands and noticed that the variable $HYPERVSTATE is initialized:

$HYPERVSTATE = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V | Select-Object State | Select State -ExpandProperty State | Out-String -Stream

which on my PC gets $null because cmdlet "Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V" returns nothing.

So the next check is going OK

if($HYPERVSTATE -eq "Enabled") { Write-Host " Hyper-V is enabled." -ForegroundColor Yellow } else { Write-Host " Hyper-V is disabled." -ForegroundColor Green }

But following check is not OK:

if ($HYPERVSTATE -eq "Disabled")

because $HYPERVSTATE is $null (in my case). So the correct way to check would be:

if ($HYPERVSTATE -ne "Enabled")

PS I guess Home edition of Windows has no Hyper-V at all, hence Get-WindowsOptionalFeature returns nothing.