Actually SharePoint Admins do a lot stuff with Powershell Scripts. Often in Powershell you get lists where data is collected in table format. Interesting for repeating Scripts you run should be the possibility to create Powershell Reports. Those Powershell based Reports are easy to create if you know how. You also can create a unique .css file to make the design for all reports identically.
Creating Powershell Reports
So if you like this idea, then you should read further more. There are a lot of posts to that topic and i started with a simple CSS file which i later used as a reference in my Powershell Script to format the output Table in the Report. The report itself is a html file. As SharePoint Admin it might be an idea, to create those reports regularly and publish it to a document library or a page, where you can see it from your desktop after update.
Create CSS File
Creating the css file with name PSHtmlReport.css as a reference for later.
Margin: 0px 0px 0px 4px;
Border: 1px solid rgb(190, 190, 190);
Background-Color: rgb(252, 252, 252);
Background-Color: rgb(0, 127, 195);
Color: rgb(255, 255, 255);
Background-Color: rgb(110, 122, 130);
Color: rgb(150, 150, 220);
Padding: 1px 4px 1px 4px;
Padding: 1px 4px 1px 4px;
I prepared three options in which i show you how you can create your report. I used some sample data which was easy to fetch up. But it’s up to you, to get your data.
Option 1 – Simple Table with CSS
#Option 1 Simple Powershell Report
Get-Process | Select -First 5 | ConvertTo-Html -CSSUri “HtmlReport.css” | Set-Content “HtmlReportOption1.html”
Option 2 – Table with Title
#Option 2 with Title
$data = Get-Process | Select -First 5;
$datum = Get-Date -Format “dd.MM.yyyy, HH:mm”
$data | ConvertTo-Html -Title “Report Prozesse” -PreContent “
Report erzeugt von $env:USERNAME am $datum
” -CSSUri “HtmlReport.css” | Set-Content “HtmlReportOption2.html”
Option 3 – Multiple Tables in one Powershell Report
#Option 3 multiple Tables in one Powershell Report
$a = Get-Process | Select -First 5 | ConvertTo-HTML -Title “Report Prozesse” -PreContent “
$b = Get-Service | Select -First 5 | ConvertTo-HTML -Title “Report Service” -PreContent “
$c = Get-WmiObject -class Win32_OperatingSystem | Select -First 5 | ConvertTo-HTML -Property * -Title “Report OS” -PreContent “
ConvertTo-HTML -body “$a $b $c” -CSSUri “HtmlReport.css” | Set-Content “HtmlReportOption3.html”
Great options to create reports based on information you have and maybe get already regularly. Try it yourself! I can imagine that you can use it, to monitor your SharePoint Farm and generate Powershell Reports from this.