Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DSCEA.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'DSCEA.psm1'

# Version number of this module.
ModuleVersion = '1.2.0.0'
ModuleVersion = '1.3.0.0'

# ID used to uniquely identify this module
GUID = '2f4af4e9-785e-46b2-829b-b1c49d8d3fbf'
Expand Down Expand Up @@ -68,7 +68,7 @@ PowerShellVersion = '5.0'
# NestedModules = @()

# Functions to export from this module
FunctionsToExport = ('Convert-DSCEAresultsToCSV','Get-DSCEAreport','Send-DSCEACSVtoSQL','Start-DSCEAscan')
FunctionsToExport = ('Convert-DSCEAresultsToExcel','Convert-DSCEAresultsToCSV','Get-DSCEAreport','Send-DSCEACSVtoSQL','Start-DSCEAscan')

# Cmdlets to export from this module
CmdletsToExport = '*'
Expand Down
95 changes: 95 additions & 0 deletions functions/Convert-DSCEAresultsToExcel.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
function Convert-DSCEAresultsToExcel {
<#
.SYNOPSIS
Creates Excel sheet file from DSCEA results

.DESCRIPTION
Used to convert the raw XML output from a DSCEA scan to a table in Excel with coloring or TRUE and FALSE

.PARAMETER InputXML
The file name (full file path) of the XML file you would like to convert to XLSX. If one is not provided, Convert-DSCEAresultsToExcel looks to the current directory for the most recently created XML file.

.PARAMETER OutFile
The new file name (full file path) of the output XLSX file. The file path must include a pre-existing folder. If one is not provided, Convert-DSCEAresultsToExcel will create output.xlsx in the current directory.

.LINK
https://microsoft.github.io/DSCEA

.EXAMPLE
Convert-DSCEAresultsToExcel

Description
-----------
Looks in the current directory for the most recently created XML file, parses the file and converts it to a XLSX file in the same directory

.EXAMPLE
Convert-DSCEAresultsToExcel -InputXML C:\Users\username\Documents\DSCEA\results.20170311-2307-31.xml

Description
-----------
Converts C:\Users\username\Documents\DSCEA\results.20170311-2307-31.xml to a XLSX file, saved in the current directory

.EXAMPLE
Convert-DSCEAresultsToExcel -InputXML C:\Users\username\Documents\DSCEA\results.20170311-2307-31.xml -OutFile C:\Users\username\Documents\DSCEA\output.XLSX

Description
-----------
Converts C:\Users\username\Documents\DSCEA\results.20170311-2307-31.xml to a XLSX file saved at C:\Users\username\Documents\DSCEA\output.XLSX
#>
[CmdLetBinding()]
param
(
[String]$InputXML = '.',
[String]$OutFile = '.\output.xlsx',
[String]$ExceptionsFile = $null
)
begin
{
if(!$(get-module�ImportExcel))
{�
if(!$(get-module -ListAvailable | Where-Object name -eq "ImportExcel"))
{
Write-Verbose "You need to install the PowerShell module ImportExcel found in the PSGallery"�
break
}
else
{
Import-Module ImportExcel
}

}
}
Process
{
(Get-ChildItem -Path $InputXML -Filter '*.xml' | Sort-Object LastWriteTime -Descending)[0] | ForEach-Object {
$results = Import-CliXml $_
$newdata = $results | ForEach-Object {
$_.Compliance | ForEach-Object {
if($_.ResourcesInDesiredState) {
$_.ResourcesInDesiredState | ForEach-Object {
$_
}
}
if($_.ResourcesNotInDesiredState) {
$_.ResourcesNotInDesiredState | ForEach-Object {
$_
}
}
}
}
}
$parsedData = $newdata | Select-Object PSComputerName, ResourceName, InstanceName, InDesiredState, ConfigurationName, StartDate
if(Test-Path $OutFile ){Remove-Item -Path $OutFile -Force}
$parsedData | Export-Excel -path $OutFile -WorkSheetname "Results" -BoldTopRow -TableStyle Medium2 -TableName "securitypolicyresults" -NoLegend -AutoSize -FreezeTopRow -ConditionalText $(
New-ConditionalText FALSE -Range "D:D" -BackgroundColor Red -ConditionalTextColor Black
New-ConditionalText TRUE -Range "D:D" -BackgroundColor Green -ConditionalTextColor Black
)



}
END
{
return Get-ItemProperty $OutFile
}
}