mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-11 05:43:17 +00:00
Added Example for PSScriptAnalyzer
This commit is contained in:
24
Examples/ScriptAnalyzer/Analyze_this.ps1
Normal file
24
Examples/ScriptAnalyzer/Analyze_this.ps1
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user