Closed kelvinkad closed 6 months ago
Hi, That looks like your system has a problem running one of the built-in cmdlets: Get-MpComputerStatus Try running just that and let me know what you see.
I just released an update. It reduces the number of times the built-in Get-MpComputerStatus
cmdlet is called. Although the issue you have must be unrelated to the hardening module but still the script uses that cmdlet more intelligently and it makes things faster.
I tried runnin only "Get-MpComputerStatus" and got the same error: Get-MpComputerStatus: Invalid Class
Now after the update, the following error: Get-MpComputerStatus: Invalid Class Get-MpPreference: Invalid Class Add-MpPreference: Invalid Class Add-MpPreference: Invalid Class Add-MpPreference: Invalid Class
I think my system is not totally compatible with this tool, it's not your fault. Besides that, there's something wrong with secure boot, I don't know why, but powershell thinks I don't have it enabled. This tool only works with UEFI???
Try uninstalling PowerShell and reinstall it again, maybe from store, if that doesn't fix it then the problem might be deeper.
These cmdlets should show if secure boot is enabled or not
Confirm-SecureBootUEFI
Get-SecureBootPolicy
The script doesn't check for UEFI specifically. What is your hardware specs?
I have an old PC, GA-78lmt Gigabyte motherboard, amd FX-6300 and 16GB RAM Sadly, Things getting worse... I tried running again and this happened:
> iex : At line:396 char:77
> + ... ble -Name 'LogPath' -Value $($PSBoundParameters['LogPath'] ?? (Join-P ...
> + ~~
> Unexpected token '??' in expression or statement.
> At line:399 char:46
> + $PSBoundParameters.Verbose.IsPresent ? ([System.Boolean]$Verb ...
> + ~
> Unexpected token '?' in expression or statement.
> At line:925 char:83
> + ... ystem.String]$ActionCheck = ($FeatureAction -eq 'Enabling') ? 'disabl ...
> + ~
> Unexpected token '?' in expression or statement.
> At line:926 char:84
> + ... stem.String]$ActionOutput = ($FeatureAction -eq 'Enabling') ? 'enable ...
> + ~
> Unexpected token '?' in expression or statement.
> At line:1024 char:64
> + ... [System.Int16]$TotalRequiredFiles = $IsLocally ? ($Files ...
> + ~
> Unexpected token '?' in expression or statement.
> At line:1122 char:39
> + Copy-Item -Path ($GUI ? $SyncHash['GlobalVars'].LGPOZ ...
> + ~
> Unexpected token '?' in expression or statement.
> At line:1122 char:38
> + Copy-Item -Path ($GUI ? $SyncHash['GlobalVars'].LGPOZ ...
> + ~
> Missing closing ')' in expression.
> At line:1120 char:27
> + if ($Offline) {
> + ~
> Missing closing '}' in statement block or type definition.
> At line:981 char:37
> + Function Start-FileDownload {
> + ~
> Missing closing '}' in statement block or type definition.
> At line:335 char:11
> + begin {
> + ~
> Missing closing '}' in statement block or type definition.
> Not all parse errors were reported. Correct the reported errors and try again.
> At line:1 char:113
> + ... eX/Harden-Windows-Security/main/Harden-Windows-Security.ps1')+'P'|iex
> + ~~~
> + CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
> + FullyQualifiedErrorId : UnexpectedToken,Microsoft.PowerShell.Commands.InvokeExpressionCommand
Looks like you're using the old PowerShell Please run this command to install the new one
Winget install Microsoft.PowerShell
@kelvinkad Hi, I just pushed a new update that automatically takes care of everything for you. You can read more about it here: https://github.com/HotCakeX/Harden-Windows-Security/pull/263
Thank you very much for that. Now the errors are very few, but don't worry, I'll try to fix it somehow, or maybe my system is not compatible with requirements of your tool.
The actual errors are:
Get-MpComputerStatus: Invalid class
Get-MpPreference: Invalid class
Add-MpPreference: Invalid class
Add-MpPreference: Invalid class
Add-MpPreference: Invalid class
Confirm-SecureBootUEFI:
Line |
2704 | if (-NOT (Confirm-SecureBootUEFI)) {
| ~~~~~~~~~~~~~~~~~~~~~~
| Cmdlet not supported on this platform: 0xC0000002
Tools category
Harden Windows Security Script
Does your system meet the requirements?
Is your Windows installation genuine?
Please explain the bug
When I try to run the commands, powershell gives the following error: Get-MpComputerStatus: Invalid Class