-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proper removing defender from Win 2016
- Loading branch information
SAPOZHKOV Aleksandr
committed
Nov 26, 2018
1 parent
0575102
commit 443d522
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
$configName = "NoDefender" | ||
Write-Host "$(Get-Date) Defining DSC" | ||
try | ||
{ | ||
Configuration $configName | ||
{ | ||
|
||
Import-DscResource -ModuleName PSDesiredStateConfiguration | ||
|
||
WindowsFeature WindowsDefenderRemoved | ||
{ | ||
Name = "Windows-Defender" | ||
Ensure = "Absent" | ||
} | ||
|
||
WindowsFeature WindowsDefenderGUIRemoved | ||
{ | ||
Name = "Windows-Defender-GUI" | ||
Ensure = "Absent" | ||
} | ||
|
||
} | ||
} | ||
catch | ||
{ | ||
Write-Host "$(Get-Date) Exception in defining DCS:" | ||
$_.Exception.Message | ||
Exit 1; | ||
} | ||
$configurationData = @{ AllNodes = @( | ||
@{ NodeName = $env:COMPUTERNAME; PSDscAllowPlainTextPassword = $True; PsDscAllowDomainUser = $True } | ||
) } | ||
Write-Host "$(Get-Date) Compiling DSC" | ||
try | ||
{ | ||
&$configName ` | ||
-ConfigurationData $configurationData; | ||
} | ||
catch | ||
{ | ||
Write-Host "$(Get-Date) Exception in compiling DCS:"; | ||
$_.Exception.Message | ||
Exit 1; | ||
} | ||
Write-Host "$(Get-Date) Starting DSC" | ||
try | ||
{ | ||
Start-DscConfiguration $configName -Verbose -Wait -Force; | ||
} | ||
catch | ||
{ | ||
Write-Host "$(Get-Date) Exception in starting DCS:" | ||
$_.Exception.Message | ||
Exit 1; | ||
} | ||
if ( $env:SPDEVOPSSTARTER_NODSCTEST -ne "TRUE" ) | ||
{ | ||
Write-Host "$(Get-Date) Testing DSC" | ||
try { | ||
$result = Test-DscConfiguration $configName -Verbose; | ||
$inDesiredState = $result.InDesiredState; | ||
$failed = $false; | ||
$inDesiredState | % { | ||
if ( !$_ ) { | ||
Write-Host "$(Get-Date) Test failed" | ||
Exit 1; | ||
} | ||
} | ||
} | ||
catch { | ||
Write-Host "$(Get-Date) Exception in testing DCS:" | ||
$_.Exception.Message | ||
Exit 1; | ||
} | ||
} else { | ||
Write-Host "$(Get-Date) Skipping tests" | ||
} | ||
Exit 0; |