Created
August 4, 2019 23:53
-
-
Save dfinke/57d357a4cf07adc5f7b4edcee2e03c02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$xlfile = "$env:TEMP\PSreports.xlsx" | |
Remove-Item $xlfile -ErrorAction SilentlyContinue | |
# Get-Process | |
$ecd = New-ExcelChartDefinition -XRange "A3:A7" -YRange "C3:C7" -Row 30 -Column 1 -Title "Report Process`nTotal Handles" -NoLegend | |
Get-Process | Select -First 5 | | |
Export-Excel $xlfile -AutoSize -StartRow 2 -TableName ReportProcess -ExcelChartDefinition $ecd | |
# Get-Service | |
Get-Service | Select -First 5 | | |
Export-Excel $xlfile -AutoSize -StartRow 11 -TableName ReportService | |
# Directory Listing | |
$excel = Get-ChildItem $env:HOMEPATH\Documents\WindowsPowerShell | | |
Select PSDRive, PSIsC*, FullName, *time* | | |
Export-Excel $xlfile -AutoSize -StartRow 20 -TableName ReportFiles -PassThru | |
# Get the sheet named Sheet1 | |
$ws = $excel.Workbook.Worksheets['Sheet1'] | |
# Create a hashtable with a few properties | |
# that you'll splat on Set-Format | |
$xlParams = @{WorkSheet=$ws;Bold=$true;FontSize=18} | |
# Create the headings in the Excel worksheet | |
Set-Format -Range A1 -Value "Report Process" @xlParams -AutoSize | |
Set-Format -Range A10 -Value "Report Service" @xlParams | |
Set-Format -Range A19 -Value "Report Files" @xlParams | |
# Close and Save the changes to the Excel file | |
# Launch the Excel file using the -Show switch | |
Close-ExcelPackage $excel -Show |
Author
dfinke
commented
Feb 2, 2020
So straightforward 😍
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment