Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid check on $HYPERVSTATE #22

Open
mbk1969 opened this issue Sep 27, 2023 · 0 comments
Open

Invalid check on $HYPERVSTATE #22

mbk1969 opened this issue Sep 27, 2023 · 0 comments

Comments

@mbk1969
Copy link

mbk1969 commented Sep 27, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant