Browse Source

#430 | DefenderServices check (edge-cases)

pull/431/head
Alan Płócieniak 2 years ago
parent
commit
10eddcd7ad
  1. 20
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 20
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 20
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 20
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 20
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 20
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

20
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -289,24 +289,16 @@ function Checks
}
# Checking services
@("Windefend", "SecurityHealthService", "wscsvc") | ForEach-Object -Process {
if ($null -eq (Get-Service -Name $_ -ErrorAction Ignore))
try
{
$services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.ServiceCommandException] {
$Localization.WindowsBroken
exit
}
else
{
if ((Get-Service -Name $_).Status -eq "running")
{
$Script:DefenderServices = $true
}
else
{
$Script:DefenderServices = $false
}
}
}
[array]$notRunning = $services | Where-Object -FilterScript {$_.Status -ne "running"}
$Script:DefenderServices = $notRunning.Count -eq 0
# Specifies whether Antispyware protection is enabled
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name EditionID) -ne "EnterpriseG")

20
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -271,24 +271,16 @@ function Checks
}
# Checking services
@("Windefend", "SecurityHealthService", "wscsvc") | ForEach-Object -Process {
if ($null -eq (Get-Service -Name $_ -ErrorAction Ignore))
try
{
$services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.ServiceCommandException] {
$Localization.WindowsBroken
exit
}
else
{
if ((Get-Service -Name $_).Status -eq "running")
{
$Script:DefenderServices = $true
}
else
{
$Script:DefenderServices = $false
}
}
}
[array]$notRunning = $services | Where-Object -FilterScript {$_.Status -ne "running"}
$Script:DefenderServices = $notRunning.Count -eq 0
# Specifies whether Antispyware protection is enabled
if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled)

20
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -271,24 +271,16 @@ function Checks
}
# Checking services
@("Windefend", "SecurityHealthService", "wscsvc") | ForEach-Object -Process {
if ($null -eq (Get-Service -Name $_ -ErrorAction Ignore))
try
{
$services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.ServiceCommandException] {
$Localization.WindowsBroken
exit
}
else
{
if ((Get-Service -Name $_).Status -eq "running")
{
$Script:DefenderServices = $true
}
else
{
$Script:DefenderServices = $false
}
}
}
[array]$notRunning = $services | Where-Object -FilterScript {$_.Status -ne "running"}
$Script:DefenderServices = $notRunning.Count -eq 0
# Specifies whether Antispyware protection is enabled
if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled)

20
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -289,24 +289,16 @@ function Checks
}
# Checking services
@("Windefend", "SecurityHealthService", "wscsvc") | ForEach-Object -Process {
if ($null -eq (Get-Service -Name $_ -ErrorAction Ignore))
try
{
$services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.ServiceCommandException] {
$Localization.WindowsBroken
exit
}
else
{
if ((Get-Service -Name $_).Status -eq "running")
{
$Script:DefenderServices = $true
}
else
{
$Script:DefenderServices = $false
}
}
}
[array]$notRunning = $services | Where-Object -FilterScript {$_.Status -ne "running"}
$Script:DefenderServices = $notRunning.Count -eq 0
# Specifies whether Antispyware protection is enabled
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name EditionID) -ne "EnterpriseG")

20
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -298,24 +298,16 @@ function Checks
}
# Checking services
@("Windefend", "SecurityHealthService", "wscsvc") | ForEach-Object -Process {
if ($null -eq (Get-Service -Name $_ -ErrorAction Ignore))
try
{
$services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.ServiceCommandException] {
$Localization.WindowsBroken
exit
}
else
{
if ((Get-Service -Name $_).Status -eq "running")
{
$Script:DefenderServices = $true
}
else
{
$Script:DefenderServices = $false
}
}
}
[array]$notRunning = $services | Where-Object -FilterScript {$_.Status -ne "running"}
$Script:DefenderServices = $notRunning.Count -eq 0
# Specifies whether Antispyware protection is enabled
if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled)

20
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -298,24 +298,16 @@ function Checks
}
# Checking services
@("Windefend", "SecurityHealthService", "wscsvc") | ForEach-Object -Process {
if ($null -eq (Get-Service -Name $_ -ErrorAction Ignore))
try
{
$services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.ServiceCommandException] {
$Localization.WindowsBroken
exit
}
else
{
if ((Get-Service -Name $_).Status -eq "running")
{
$Script:DefenderServices = $true
}
else
{
$Script:DefenderServices = $false
}
}
}
[array]$notRunning = $services | Where-Object -FilterScript {$_.Status -ne "running"}
$Script:DefenderServices = $notRunning.Count -eq 0
# Specifies whether Antispyware protection is enabled
if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled)

Loading…
Cancel
Save