microsoft / DSCEA

DSC Environment Analyzer (DSCEA) is a simple implementation of PowerShell Desired State Configuration that uses the declarative nature of DSC to scan systems in an environment against a defined reference MOF file and generate compliance reports as to whether systems match the desired configuration.
https://microsoft.github.io/DSCEA
Other
197 stars 41 forks source link

DSCEA needs the ability to define exceptions for scan reports #16

Open rkyttle opened 7 years ago

rkyttle commented 7 years ago

I had already created a solution for the tactical version, here is an example command

Get-DscEaPowerBiReport -ExceptionsFile 'C:\Users\ralph\Documents\DSCEA-exceptions-clean.ps1'

Here is an example of an exceptions file:

$OutPath = "$env:ProgramFiles\DSCEA\Output"

#Remove Global exceptions from results
$DataMinusGlobalExceptions = Import-Csv $OutPath\DAY.CSV |
Where-Object {($_.ResourceName -ne "Registry" -or $_.InstanceName -ne "Numberofpreviouslogonstocache") -and
($_.ResourceName -ne "Service" -or $_.InstanceName -ne "MicrosoftAntimalwareService") #-and
#($_.ResourceName -ne "WindowsFeature" -or $_.InstanceName -ne "XPSViewer")
}

#Remove individual system level exceptions
$DataMinusExceptions = $DataMinusGlobalExceptions |
Where-Object {($_.PSComputerName -ne "dsctest31" -or $_.ResourceName -ne "WindowsFeature" -or $_.InstanceName -ne "Bitlocker") -and
($_.PSComputerName -ne "dsctest31" -or $_.ResourceName -ne "WindowsFeature" -or $_.InstanceName -ne "EnhancedStorage") -and
($_.PSComputerName -ne "dsctest32" -or $_.ResourceName -ne "WindowsFeature" -or $_.InstanceName -ne "DHCPServer")
}

$DataMinusExceptions | Export-Csv -Path $OutPath\DAY.CSV -NoTypeInformation
rkyttle commented 7 years ago

Adding previous comments from Keith

@{
    ComputersToExempt = @('server1','server2')
    ItemsToExempt = @('AntiMalware')
    ComputerItemPairsToExempt = @{
        'server3' = @('DNSServer')
        'server4' = @('DNSServer','NumLogons')
    }
}

Then we can use Get-PowerShellDataFile or whatever it's called, and do a few -notin $Data.ComputersToExempt type commands