From 978e8d38b5a33c48c6770eea86dc65ad51ab943c Mon Sep 17 00:00:00 2001 From: jhoneill Date: Thu, 2 May 2019 16:34:00 -0700 Subject: [PATCH] Added Example for PSScriptAnalyzer --- Examples/ScriptAnalyzer/Analyze_this.ps1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Examples/ScriptAnalyzer/Analyze_this.ps1 diff --git a/Examples/ScriptAnalyzer/Analyze_this.ps1 b/Examples/ScriptAnalyzer/Analyze_this.ps1 new file mode 100644 index 0000000..f5ee3ad --- /dev/null +++ b/Examples/ScriptAnalyzer/Analyze_this.ps1 @@ -0,0 +1,24 @@ +$xlfilename = $pwd.path -replace "^.*\\(.*?)\\(.*?)$", '$1-$2.xlsx' +$xlpath = Join-Path -Path $env:TEMP -ChildPath $xlfilename +Remove-Item -Path $xlpath -ErrorAction SilentlyContinue + +$ScriptAnalyzerResults = Invoke-ScriptAnalyzer . + +$xlPkg = $ScriptAnalyzerResults | Group-Object -Property RuleName -NoElement | Sort-Object -Property Name | + Select-Object -Property Name,Count | + Export-Excel -Path $xlpath -WorksheetName Summary -AutoSize -PassThru + +$params = @{ + WorksheetName = 'FullResults' + AutoSize = $true + AutoFilter = $true + IncludePivotTable = $true + Activate = $true + PivotRows = 'Severity', 'RuleName' + PivotData = @{RuleName = 'Count' } + IncludePivotChart = $true + ChartType = 'BarClustered' + Show = $true +} + +Export-Excel -ExcelPackage $xlpkg -InputObject $ScriptAnalyzerResults @params \ No newline at end of file