Skip to content

Commit

Permalink
proper removing defender from Win 2016
Browse files Browse the repository at this point in the history
  • Loading branch information
SAPOZHKOV Aleksandr committed Nov 26, 2018
1 parent 0575102 commit 443d522
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions infrastructure/images/nodefender.ps1
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;

0 comments on commit 443d522

Please sign in to comment.