Building a Daily Systems Report Email With PowerShell

A combination of PowerShell and HTML can provide the basis of an easily-scanned report on the basic state of a whole group of servers. Sean combined a range of routine health-checks to provide himself a useful range of information about his servers to his in-box.

Introduction

A little while ago, I demonstrated a way to create a fairly simple disk space report using PowerShell that would be e-mailed to you whenever one of your servers started to get low on disk space. This was done to help solve a commonly occurring issue that I had to deal with; ensuring that servers did not get to low on disk space. I quickly realised that there are many other ‘health checks’ that I often find myself performing on various servers in my day-to-day job. This got me thinking: It would be great to have a more complete systems report that would be e-mailed through on a daily basis, detailing common statistics and information which would otherwise be a bit of a hassle to gather manually.

1459-report.png

Part of a report, showing the HTML formatting and piechart

Once this report was built, it could also serve as a base for other ‘modules’; allowing anyone to add their own bit of functionality. With this in mind, I set about to achieve this goal of creating an automated systems report with a bit of PowerShell magic.

What else can we report on or monitor?

With PowerShell, I like to believe that just about anything is possible. I am constantly finding more and more tasks that can be achieved using this wonderful scripting language. The answer is therefore “anything really”.

We are going to build a systems report that will convey useful information for every server in a list of server names. Too often I find myself staring at dull, boring PowerShell reports that have been converted to HTML. Not in this case! We’ll be using the Microsoft Chart Controls for .NET 3.5 to add some fancy charts to this to keep our report interesting (and easier) to read. The script will aim to gather all of this information, and then e-mail it all across to you. To save a bit of time, we’ll be leveraging the disk space report script I wrote about here.

By modifying this Systems Report, you could easily build something that is customized more to your setting – perhaps you could report on other services running on your servers, or modify the Create-PieChart function to build charts for other services or performance data.

Here is a list of items we’ll be reporting on for each server in the list:

  • System Information
    • System Uptime
    • OS
  • Memory (RAM) Free and Used figures (we’ll also put these into a pie chart)
  • Disk Information
    • All disks with space less than X (Threshold specified)
  • System Processes
    • Top 10 Highest Working Set Memory Usage processes
  • Services
    • Any services that are set to “automatic startup”, yet are found to not be started.
  • System and Application Logs
    • The last few System or Application Event Logs that were of Error or Warning type

Breaking down the Report Script

To keep things as customizable as possible, I have tried to create the reporting script in a reasonably modular fashion. Therefore, each section of information that the script reports on relies on a PowerShell function or cmdlet that retrieves or builds the information we are after. Let’s break the script down and go through what makes things tick. You can download the script here to follow along.

To start with, in the region named “Variables and Arguments”, we define our customizable variables and parameters such as:

  • Mail Server settings (so that the script will email the report to us and knows which SMTP Server to use to send the report).
  • Thresholds and Script customizations (so that you can customize the report to give you as much or as little information you need in the final daily report).
  • Low Disk Space threshold. By default this is set to 20%.
  • Number of Warning or Error type event logs to report on ($EventNum). By default this is set to 3 to retrieve the last 3 event log entries for each Event Log section on each Server.
  • Computer/Server list – the variable called $list accepts a text file as an argument. This is mandatory for the script to run – you basically feed a list of computer names in to the script when it is run, and this variable is populated with that list of computer names.
  • Lastly, “$Report = @()” creates an empty array variable which we’ll use throughout the script to temporarily hold information for each section that uses this variable.

The Variables and Arguments region

We then have a region defined for the various Functions we’ll be using. Let’s go through these functions one at a time. The first function we have is called “Create-PieChart“. This function relies on the Microsoft Chart Controls for Microsoft .NET Framework 3.5 and allows us to generate a graphical chart on the fly in our script and output it to a .PNG graphic file. So do make sure that the system that is running this script has the Chart Controls installed (don’t worry, as it has a very small system footprint).

The function to create a piechart

As this is a custom function created just for this report, let’s run through it in detail. We begin by loading the assemblies needed to use the .NET Chart components. (System.Windows.Forms and System.Windows.Forms.DataVisualization).

1459-piechart.PNG

We now create our chart object and define the size of the chart graphic that we want. You can of course adjust the dimensions defined here depending on how large or small you would like your charts in the report to be.

Next we define a Chart Area, which is where our data will be plotted. This is done using the “New-Object” cmdlet. Once created, we add the Chart Area to the Chart object we created beforehand. We then add a data series to the chart, and move on to actually filling the chart with data by taking the arguments passed into the Create-PieChart function and creating data points with these arguments. (The foreach loop will go through each argument and create a data point, then add it to the Data Series).

Now we specify the chart as a pie chart type, and specify some cosmetic settings for our chart such as the label and drawing styles. Lastly we save the pie chart out to a .PNG file in the same directory that the script is being run from.

Our next Function is called “Get-HostUptime“.

The function to Calculate the Host uptime

This is a fairly simple PowerShell function which has a nice self-explanatory name. It takes a parameter called ComputerName and uses this in a Get-WMIObject call to fetch various Operating System information from the computer specified. The script then singles out the “LastBootTime” property and figures out the uptime value by subtracting “LastBootTime” from the current time and date (which is fetched by using a simple “Get-Date” call). A nicely formatted uptime value is returned at the end which will display nicely in our Report for each system.

For our HTML report to look half decent, we need to specify some HTML and CSS. We build the HTML header into an array called $HTMLHeader. This contains some standard HTML header code as well as some CSS for the various headings, text and more importantly, tables in our report. This will apply to all the plain tables that are generated by PowerShell in our final report and present us with something more interesting to look at in the final product.

The HTML Header ‘HereString’

Now we’ll look at the primary work horse of our reporting script – the main “foreach” loop. In this section, for every computer (server) listed in our $computers list, we loop through the various PowerShell script and cmdlets that retrieve the other information we will be reporting on, all the while appending this information to our $HTMLMiddle array which holds the bulk of our report. In this way, we can loop through every computer or server, gather the information we are looking for, and store it in this array. At the very end of the script we will add the HTML Header, Middle, and End sections together, giving us our final report. Let’s have a quick look at what the main loop covers then…

Starting off, we use the familiar disk space reporting script I talked about earlier to fetch information about any disks that are below the specified threshold percentage in disk space. For this we use the Get-WMIObject cmdlet to gather the relevant information and convert it into an HTML table by piping the output to the ConvertTo-HTML cmdlet at the end.

The Disk space Reporting script

The Operating System name for the current machine is gathered and stored into the $OS variable. To report on Memory figures for each computer or server, we fetch some more Operating System information and store this in the $SystemInfo variable, again using the Get-WMIObject cmdlet. From this point, we then break this up into other variables to store figures such as the Total, Free and Used RAM for each system. We clean up this information a little bit by using built-in [Math] functions to round off the decimal places on each figure.

The System Info Region

Next we’ll gather the top ten (default setting) system processes in terms of those which are using the most memory (Private Working Set memory). This one-liner employs the use of the “Get-Process” cmdlet to get a list of the top processes from the specified machine and select the ones we are interested in. It then sorts these on the Working Set Property in descending order and builds us another HTML table of the results to add to our now growing report. As you’ll notice, this information is stored in the $TopProcesses variable.

Listing the top ten system processes in terms of memory used

Moving on, the Services Report is generated by first declaring an array to use ($ServicesReport) and then fetching a list of services on the machines that are: a) set to “Automatic Startup” and b) currently in a “stopped” state. We do this with a simple “Where” clause in our cmdlet to check for any services that are Stopped and in Automatic Startup mode. After this, we loop through each service in our list of services that were gathered and build a row for our services table, adding information about each service to our row, such as; Name, Service Status and Start Mode. This will give us a good idea of what each service is and what its current state is when viewing the final report each day. Through each loop (each service object we loop through), our $ServicesReport array has the row added. Finally we convert the Services Report into an HTML table for later use in our final report.

The Services report

We then have a similar section called the “Event Logs Report” region. We use the same method we used for gathering the Services information, but this time we use the PowerShell cmdlet for fetching Event Logs called “Get-EventLog“.

The Events Log report

There are two arrays we build this time – one for System Events ($SystemEventsReport) and one for Application Events ($ApplicationEventsReport). We do this by simply changing the “LogName” parameter for the “Get-EventLogs” cmdlet. In each instance, we convert the final array/table into an HTML table where we later add it to our final HTML report.

Remember that Function we defined at the start called “Create-PieChart“? Well, we’ll now use this to generate our pie chart diagram of memory usage and output the file to the current working directory of our script. Now that we know what our Memory usage figures are (and have these stored in variables) we can specify these figures as parameters in our Create-PieChart function and actually generate the chart. Our chart’s filename is unique as it contains the name of the current computer/server being iterated through in our script ($computer).

Creating the Piechart

Just after creating the pie chart, we also add the name of the file that was outputted into an array called $ListOfAttachments. Right at the end, when sending our report out via e-mail, we’ll specify this array for the list of attachments to add to the e-mail (so that our report e-mail has all the images it needs of course)!

The last bit of our main loop ensures that all of the information gathered thus far is added to the $CurrentSystemHTML array. This is a little bit of a tedious section as we manually create some HTML headings and tables using common HTML tags. We also embed our chart image in the HTML using an <IMG> tag. The reason this all needs to be added in the loop, is because this information is all relevant to the current computer or server being looked at by the script. At the end of the loop, you’ll see that we append this HTML to the $HTMLMiddle array where it is stored for the end of our report. Each successive loop of this foreach main loop will add the next system’s information to $HTMLMiddle until we are finished.

The ‘tedious’ end to the main loop.

Finally, we create the $HTMLEnd array which just adds a few closing tags. We then create our final “$HTMLmessageby adding $HTMLHeader, $HTMLMiddle and $HTMLEnd. By piping $HTMLmessage to “Out-File” we can save the report out to an actual HTML file on the hard disk. We also use the “Send-MailMessage” cmdlet to send us our e-mail with the $HTMLmessage as the body of our e-mail. As long as you provided your SMTP server and address details, after running this script you’ll soon have your first system report arriving in your Inbox!

Adding the end tag and sending the email report

Closing off

It is often difficult to be proactive on the job when you constantly have to chase down issues and monitor various remote systems across the network. This is a clear cut case for using PowerShell to help you automate various checks and to repeat those processes that you often find yourself having to do manually. Hopefully this Systems-Reporting script will help bring useful information about your servers directly to your Inbox, as well as catch anything out of place before it becomes too much of an issue.

By modifying the report above you could easily build something that is customized more to your own environment – perhaps you could report on other services running on your servers, or modify the Create-PieChart function to build charts for other services or performance data for example. The sky is the limit when it comes to what PowerShell can do, so do try to think of other areas to report on and get scripting! If you would like to get an idea of what the final report looks like without trying the script yourself, here is a sample I generated from a list of six, Windows Server 2008 R2 machines on a domain. Please do feel free to add any ideas or customizations you may have thought of in the comments section.

The source of the PowerShell script, and a sample report, is in the download link below. You’re welcome to modify it for your own particular requirements.

For more articles like this, sign up to the fortnightly Simple-Talk newsletter.

Downloads

Tags: , , , ,

  • 135926 views

  • Rate
    [Total: 90    Average: 4.6/5]
  • kin

    Building a Daily Systems Report Email With PowerShell
    Excellent use of Powershell with nice looking graphs.

    Only concern is that we have more than 400+ Prod servers in our environment, so generating and sending out the report will be huge.

    Do you know how we can connect to Linux/Unix servers using Powershell to pull out the same info ?

    Cheers

  • Shogan

    Server use / Linux Use
    Hi kin,

    Thanks for the comment!

    Yes, that is a rather large environment to run this against! I found that the script only took a few seconds to run against 10x Windows Server 2008 R2 machines so I wouldn’t imagine it taking too much time to run against that number. I would however recommend testing it against a pre-production environment first if possible, or perhaps a smaller subset of servers in a list at first.

    To keep the size down, you could potentially modify the script to capture the details of 20 servers at a time, send off the email, then do the next 20 for example. You could also play with presets to tone down the number of event log or process entries that are pulled out and put into the report. I think the script should be fairly customisable from that point of view, and hopefully allow you to modify it to suit your kind of environment.

    With regard to your Linux/Unix servers, that is a whole other ball game when it comes to PowerShell. I don’t know of any easy way, however I have recently been playing around with SharpSSH and wodSSH libraries for PowerShell which have allowed me to SSH into servers and execute remote commands against servers, then pull the info generated from these commands back into PowerShell. It may be worth having a look at these libraries to see if they may help.

    I hope that helps!

    Sean

  • Dkorzennik

    400+ prod servers
    Hi. I have a similar scenario and do a similar collection of data using powershell. In South Africa a lot of our servers are across slow (by world standards) WAN links. So just authenticating takes a while. How I get around the time to capture the data on all the servers, and also not have the data collected in a serial fashion, but rather in parallel, is to spawn multiple PS threads, using start-job cmdlet. The trick is to create a scriptblock variable, with all the information, functions, modules and snappins that you need in the job and pass this script block to the start-job. Also, the server names, from a list, or in our case, a query against a SCOM server, must also be passed in as arguments. I then batch the 300+ servers into 25 batches. I then fire off the 1st batch of about 13 servers jobs, do a start-sleep for a few minutes, and then fire off the next batch, in a while loop. I do this batching because if I fire off 300+ start-job processes the server that this is running on is overwhelmed but all these processes and by the data being returned. I can get information like database info, data file info, log file info and whatever else I want in about 15 minutes for 300+ servers. If you need pseudo code for the above, drop me a msg.
    David

  • Dkorzennik

    400+ prod servers
    Hi. I have a similar scenario and do a similar collection of data using powershell. In South Africa a lot of our servers are across slow (by world standards) WAN links. So just authenticating takes a while. How I get around the time to capture the data on all the servers, and also not have the data collected in a serial fashion, but rather in parallel, is to spawn multiple PS threads, using start-job cmdlet. The trick is to create a scriptblock variable, with all the information, functions, modules and snappins that you need in the job and pass this script block to the start-job. Also, the server names, from a list, or in our case, a query against a SCOM server, must also be passed in as arguments. I then batch the 300+ servers into 25 batches. I then fire off the 1st batch of about 13 servers jobs, do a start-sleep for a few minutes, and then fire off the next batch, in a while loop. I do this batching because if I fire off 300+ start-job processes the server that this is running on is overwhelmed but all these processes and by the data being returned. I can get information like database info, data file info, log file info and whatever else I want in about 15 minutes for 300+ servers. If you need pseudo code for the above, drop me a msg.
    David

  • Anonymous

    Thanks
    I had been planning a similar script but this saves me the effort. Thanks again.

  • Shogan

    400+ prod servers
    Hi Dkorzennik,

    Thanks for the feedback – very interesting scenario you have there. In fact, I can even relate as I am originally from S. Africa myself and had to deal with 64k local municipality WAN links a number of years back! Thanks for the info – I haven’t really used the Start-Job/Receive-Job cmdlets yet so I’ll definitely be taking a look at them now that you mention it.

    If I run into any trouble working with the cmdlets I’ll definitely drop you a message over here to find out more, but imagine I should be fine after using get-help on the cmdlets 🙂

    @Anonymous, thanks for the feedback – glad you have found this useful!

    Sean

  • Anonymous

    Monitoring Da Farm
    Why reinvent the wheel? Just use SCOM.

  • eddiechits

    Integration with sharepoint
    Great stuff just what l need, tell me is it possible to publish the output onto sharepoint?

  • Shogan

    sharepoint publishing
    Hi eddiechits,

    Yes, this should be possible. Seeing as though the report is output to an HTML file and some .PNGs for the graphs, you should be able to use something like this to send the files up to Sharepoint via PowerShell. http://poshcode.org/2122 Give it a try and let us know if that works… 🙂

    Cheers,
    Sean

  • avijitd

    Power Shell Script on Print Logs
    Hello Sean… First of all thanks for this Post.. Its really helpful for me to monitor the servers. Thanks a Ton.

    Need small help from you. I want one PowerShell Script which will fetch all the print events from the print server and prepare one excel/HTML report on monthly basis with fields like Printer Shared Name, IP Address, User Name, Document Name, No of Pages Printed, Date & Time etc. and then send that report to mentioned email ID’s.
    Is possible we can we format the report headings.

    Eagerly waiting for your reply…

    Thanks in advance…

  • itznfb

    CSS
    I’m having no luck getting the CSS configuration to apply to the html output. It’s all there but it just doesn’t take affect. Anyone else see this behaviour?

  • Paulexander

    Advice on extending it?
    This is absolutely great, thanks for sharing this. Looking forward to getting this going today.

    Do you have any advice on what someone needs to do to extend or edit this? I have a couple of other things I might want to add…

  • shovan

    Connect to multiple SQL instances through Powershell
    Hi Sean,

    Thanks a lot for sharing this really useful script.

    Could you please let me know if similar kind of script can be created to perform SQL monitoring for multiple instances ? If yes, then it will be really great if you can share how multiple sql instances can be connected from a list of SQL instances.

  • Shogan

    replies!
    @Paulexander – what are you looking at adding? If you can find a PowerShell cmdlet that works with the objects you are looking at, the best thing to do is to type "get-help cmdletname" in PowerShell and have a read there – all cmdlets have excellent built-in help 🙂 Otherwise, drop me a message here or on twitter with what you are looking for and I’ll try help out!

    @shovan – I am not really a SQL guru so can’t be of much help there… However another author here, Laerte Junior is quite clued up with both SQL and PowerShell and his articles on Simple-Talk might give you some good ideas… Hope that helps!

    @itznfb – perhaps it is the web browser you are using? Have you tried the latest Chrome version? I used Chrome predominantly to test this script when creating it…

    @avijitd – I know its an old reply, but see my reply to Paulexander above – best thing to do would be to look for any cmdlets in PowerShell relating to printing and look up their help – give that a go, create a simple script that achieves the first bit you are trying to do, and keep building to it like that – you’ll be surprised at how easy PowerShell is to pick up once you get going! 🙂

    Cheers,
    Sean

  • shovan

    reply
    @Sean- Thanks a lot!! Probably, I can make use of Larte’s existing script on Simpletalk – http://www.simple-talk.com/sql/sql-tools/the-posh-dba-grown-up-powershell-functions/

    Will share it in here is I am able to create it 🙂

  • Newguy

    Something strange
    Just wanted to start of with saying.. how awesome this script is.

    I just seem to be having one little issue,
    when the report generates I get about half a page of blank data, then one or two of the servers will be in the report with some of the data, then the last 3 entries have the data I need.

    any reason this could happen?
    I am running this script against 3 servers in a windows cluster enviroment ( not hyper-V ).

  • flavor4real

    email error
    Hello,
    This is a very good script. I’m getting a error and wanted to see if someone can point me in the right direction.

    Send-MailMessage : Unable to connect to the remote server
    At C:UsersusernameDocumentsScript_RepositorySystemsReport.ps1:291 char:17
    + send-mailmessage <<<< -from $fromemail -to $users -subject "Systems Report" -Attachments $ListOfAttachments -BodyAsHTML -body $HTMLmessage -priority Normal -smtpServer $server
    + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

    Thanks

  • davey-kb

    .NET 4.0 chart controls
    Will the chart controls for .NET 4.0 be okay?

    Thanks!!

  • davey-kb

    .NET 4.0 chart controls
    Will the chart controls for .NET 4.0 be okay?

    Thanks!!

  • davey-kb

    .NET 4.0 chart controls
    Will the chart controls for .NET 4.0 be okay?

    Thanks!!

  • davey-kb

    wierd multiple posts.
    Sorry, not sure why. I’m going to clear my internet cache. sorry again. everytime I refresh my page it posts again.

  • stang32

    Something strange posted by NewGuy
    I had a similar issue where the first part was blank. After fiddling, I ran the script from CMD and it worked.

  • conivingmedal

    pie chart
    How would I just do pie charts for disks and make them red if need more disk or green if ok?

  • Shogan

    pie chart
    @conivingmedal,

    You would need to play with the Create-PieChart function. Instead of feeding it parameters for $FreeRAM and $UsedRAM you would need to feed it the disk capacity and disk free space as variables. For example $capacity and $diskfree if you added those to the report script. To play with the colours, you would need to look at what properties were available and see if you can find one that allows you to specify colours. You could then do a calculation and an IF statement to say that if the result is lower than the threshold, it should give the chart a red/orange colour scheme for example.

    The replies below are old, but thought I would answer anyway!

    @davey-kb, I have not tried the .NET 4.0 controls but in theory they should work fine and be backward compatible!

    @stang, glad you got it working!

  • mberry1212

    Run this as a scheduled task
    Hi,

    I’ve been unable to have this successfully run as a scheduled task.

    When it runs, I get the email but there is no data. If I run the same script manually everything is there. I’m assuming this is related to a timeout and the script hasn’t gotten the data back before sending the email. How can I set this script to run daily as a scheduled task?

  • Shogan

    troubleshooting
    Hi mberry,

    I would suggest trying out the troubleshooting in this forum thread: http://exchangeserverpro.com/forums/exchange-server-2010/3472-scheduled-powershell-problem-get-mailboxreport-ps1.html

    In particular, try the suggestion of running the batch file that calls the script from cmd prompt to look for any possible errors that are appearing when the script tries to attach the report. I suspect it may be to do with paths…

    Cheers,
    Sean

  • TechKnow

    Access denied
    I really have to hand it to you. I have been working on something much simpler, and have been looking around to see what else is out there. This is the most efficient script that I have seen. Additionally, the presentation is superb. Props.

    I get a progression of access denied errors when I run the script. I am guessing that I need to put a -credentials attribute in there somewhere, but I am not sure where.

    Again, this script is outstanding.

  • Shogan

    Access denied
    Hi TechKnow,

    Thanks for the comment and feedback. Good to see this is still proving useful!

    I still have it set to run against some core servers I work with and it e-mails me a report each morning.

    Yes, the access denied messages are probably to do with credentials for servers – play around with the credentials attribute and you should be able to get it working.

    Cheers,
    Sean

  • TechKnow

    Got it
    I got it. I just have to run it from inside the domain. I can’t auth from the net. N/P just have to get the email bit working.

    Thanks again!

  • TechKnow

    Anomaly
    I have gotten it working and it runs like a champ. It is truly an outstanding script.

    There are only two small issues:

    1.) It will only send to one email address (this is not really an issue because I am just going to set up a distro and send there"

    2.) When I run the report (on let’s say two servers) in my test environement, it runs fine, the second time I run it, the reports contains the original report and the new one (it shows reports for both servers twice), if I run it again, same thing happens (it shows both servers 3 times)

    It is apparently saving data between results…

    Any ideas?

  • Shogan

    Hi
    Glad to see you have it running now.

    1. Yes, distribution list, or the e-mail cmdlet may even accept a comma separated list of e-mails to send to if I recall correctly.

    2. Are you running the script in a loop (while..do for example)? Otherwise that seems a bit odd. If you call the batch file to run the script once every so often as a scheduled task it shouldn’t duplicate date. What you could do is at the end of the script logic after the full report is built by doing this, and then subsequently e-mailing the content of $HTMLmessage:

    $HTMLmessage = $HTMLHeader + $HTMLMiddle + $HTMLEnd

    send-mailmessage -from $fromemail -to $users -subject "Systems Report" -Attachments $ListOfAttachments -BodyAsHTML -body $HTMLmessage -priority Normal -smtpServer $server

    You could set the $HTMLMiddle = $null

    That way the report content is cleared before the next run. Make sure you set it to $null after the report is e-mailed out using send-mailmessage though.

    That should do the trick I believe 🙂

    Cheers,
    Sean

  • TechKnow

    Thanks!
    I will see if I need to even tweak it. My guess is, it will be fine. It appears that after a bit of time it clears whatever cache it has and operates as would be expected.

    Whoever you are working for needs to give you a raise.

  • zerocool18

    Optimized using Remoting
    Thanks for Sharing. It’s very useful. I added one more feature to "List Shared Folders". Also, I’ve applied remoting and it has become blazing fast!
    I’ll share the link soon.

  • Gary80

    list.txt location query
    where must the list.txt file be located?

  • Gary80

    list.txt location query
    where must the list.txt file be located?

  • Shogan

    replies
    @zerocool18: You legend! Thanks for taking the time to look at extending the report.

    @Gary80: It could in theory be located anywhere, but in this article’s example, I store it in the same folder as the PowerShell script itself. Hence when you edit your batch file that calls the script, it refers to the text file with no other path, other than the filename itself (list.txt). So keep it in the same folder.

    Sean

  • Sylar

    cannot read list.txt
    I get the following eror;

    Get-Content : Cannot bind argument to parameter ‘Path’ because it is null.
    At C:scriptsSystemsReport.ps1:10 char:25
    + $computers = get-content <<<< $list #grab the names of the servers/computers to check from the list.txt file.
    + CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentCommand

    The list.txt is in the same folder as the script

    Please help

  • Harvey

    Adding CPU value export to CSV
    Hi,

    Whatr would be the best way to add a CPU value into this?

    Also would it be possible to export data values to csv?

    Cheers

  • Harvey

    Adding CPU value export to CSV
    Hi,

    Whatr would be the best way to add a CPU value into this?

    Also would it be possible to export data values to csv?

    Cheers

  • Harvey

    Adding CPU value export to CSV
    Hi,

    Whatr would be the best way to add a CPU value into this?

    Also would it be possible to export data values to csv?

    Cheers

  • Harvey

    Adding CPU value export to CSV
    Hi,

    Whatr would be the best way to add a CPU value into this?

    Also would it be possible to export data values to csv?

    Cheers

  • Harvey

    Adding CPU value export to CSV
    Hi,

    Whatr would be the best way to add a CPU value into this?

    Also would it be possible to export data values to csv?

    Cheers

  • Harvey

    Adding CPU value export to CSV
    Hi,

    Whatr would be the best way to add a CPU value into this?

    Also would it be possible to export data values to csv?

    Cheers

  • Shogan

    reply
    Hi Harvey,

    for some reason you comment keeps on getting spammed in. Careful you don’t keep refreshing the page after having submitted one- I have found this sometimes duplicates posts on Simple-talk 🙂

    To answer your question -> It would be easy to add CPU values in. Just simply duplicate a section of the PowerShell code that handles one bit – such as services, and use a different WMI query. You can do a search on google for the msdn documentation on WMI queries and find the WMI query reponsible for CPU info.

    Regarding CSV, you can use the ConvertTo-Csv cmdlet in PowerShell. So where you for example use:

    $ServicesReport = $ServicesReport | ConvertTo-Html -Fragment

    to convert the services module report to HTML, you could also add a line just above that like this:

    $ServicesReport | ConvertTo-Csv | Out-File myreport.csv

    This should pipe everything in $ServicesReport to Csv and into an output file in the same directory called myreport.csv. That is off the top of my head, but it should do the trick.

    Cheers,
    Sean

  • Harvey

    Thanks
    Hi Sean,

    I saw the duplicates too I think my workstation was having a bit of a fit!!

    I sort of figured the CPU section out (plus a few other extra’s 🙂 ) by adding this –

    $SystemCPU = gwmi win32_processor -computername $computer | Measure-Object -property LoadPercentage -Average | Select Average

    However in the report I get this – @{Average=52.25} as the value which I am still trying to figure out.

    Ill give the csv code a go as well. I’d also like to attach that to the email as well but that looks fairly straighforward!

    Thanks for replying and for the main script as well.

    Harvey

  • Shogan

    reply
    Hi Harvey,

    Great – glad you got it going. Try look for an "Average" property on the $SystemCPU variable – so try something like $SystemCPU.Average instead of just $SystemCPU when you output it in your report – that should sort out the @{…} bit.

    Cheers!

  • Harvey

    Average
    $SystemCPU.Average that sorted that out thanks.
    Not having any luck with exporintg to csv So I’m goign to spilt out the relevant sections and do that seperately i think.

  • rcx001

    Performance counters
    Hello, nice script! How would I add performance counters? I’m still new to PS and can gen up the counters but still new to exporting info to HTML. Can you give me an example? Thanks!

  • anandfranklin

    Enable CPU Usage Information in this script
    Hello Sean,

    Recently, I came across this PowerShell script (SystemsReport.ps1) and found to be very useful in getting the real-time information from multiple servers, except for the CPU information which need to be captured via the same script.

    What information should be added under which line, please help me on this.

    Thank You, Anand

  • Shogan

    replies
    Hi @rcx001 and Anand 🙂

    Seems both of you guys could use more WMI queries to get what you are looking for.

    So, rcx, you probably want to look into retrieving perf counters using Get-WMIObject. Just as we do with other bits of info in this report, you can do something similar. Here is an article that has an example of getting some CPU perf stats: http://itknowledgeexchange.techtarget.com/powershell/wmi-and-performance-counters-i/

    @Anand, you’ll also want to use Get-WMIObject to fetch info about the target remote machines’ CPUs. Here is an excellent example: http://blogs.technet.com/b/heyscriptingguy/archive/2011/09/26/use-powershell-and-wmi-to-get-processor-information.aspx

    Cheers,
    Sean

  • soetie

    pdf
    Is it possible to add a pdf writer? so we have directly a pdf

  • mtorres

    Only servers that fall within the percentage listed
    Currently the report will show every server I list and the section with the hard drive info will only show the drive if it falls below the percentage you put . My question is how to I get it to ONLY email the servers who’s disk space is below the percentage? In other words I don’t want the info for every server UNLESS the disk space is below what I put.

    Thanks and you are the bomb, this script rocks

  • mtorres

    Only servers that fall within the percentage listed
    Currently the report will show every server I list and the section with the hard drive info will only show the drive if it falls below the percentage you put . My question is how to I get it to ONLY email the servers who’s disk space is below the percentage? In other words I don’t want the info for every server UNLESS the disk space is below what I put.

    Thanks and you are the bomb, this script rocks

  • Shogan

    RE: Only servers that fall within the percentage…
    What you would want to do then is when this line is run:

    $HTMLMiddle += $CurrentSystemHTML

    You would want to check the $DiskInfo variable – if this contains any data for the current computer being evaluated in the foreach loop, then this means that the system has disks with less than X % freespace. You can use a simple if check here to not add the $CurrentSystemHTML to $HTMLMiddle if there is no information about disks with less than X % freespace. If there are, then you run the:

    $HTMLMiddle += $CurrentSystemHTML line as per normal.

    That is a quick and simple method, but there are of course more efficient ways of doing this 🙂

    Thanks for the comment/feedback!

    Sean

  • bi34lz

    Great script
    Fantastic script, thanks for sharing.

    Just wondering whether it would be possible for a similiar script to be created, that runs throughout the day, to capture CPU / RAM and Disk utilization, and then creates an HTML report at the end of the month showing the uptime and a pie chat of CPU / RAM and Disk utilization over that month?

  • peandaddy

    Email body Content appended, Null values appended
    Hi,
    I use the script to run SQL report. There are 2 issues.
    1. It the table has 10 rows, none of them are what I want. But they will still show empty in the HTML body content.

    2. I ran the script on ISE manully, if there is a value. Every time I run the script, the body content will increase the same content unless I closed PowerShell ISE.

  • mrsumon

    I Would like to add CPU utilization,
    Hi,

    Thanks a lot for sharing the great script. Its working fine, but I would like to have below thing to added into the script and get the html email output. Could you please advise how to add them.

    I Would like to add CPU utilization, Check disk health (S.M.A.R.T.), IIS monitoring vai perfmon counter, OS Antivirus status, Security event logs monitoring,

  • Zack

    Running 20 times?!!?
    Hi – I love this script! It’s brilliant, but for some reason it’s running exactly 20 times.

    I’ve tried to modify it, as we only have 1 server to monitor, so I’ve included ‘SERVER1’ instead of the list.txt, but even using the original script (and just putting SERVER1 in a text file) still sends as one email, but the same stuff 20 times.

    I’m using Server 2012 R2. Windows Powershell LSE apparently…. (I just used the ‘run with powershell’ command)

    Thanks if anyone has any ideas on why it’s repeating itself!?

  • Zack

    Fixed?
    Think I may have fixed it – when running in powershell editor by pressing F5 it seems to break and not apply my changes properly either…. by saving and then running externally it’s fine.

    Hope this hels someone! 🙂

  • soetie

    gmail
    How can i add my gmail credentials so that the report gets email every month to my mail

    im gettings now error that a secured connection is needed

  • Shogan

    Replies!
    Hi Zack,

    Well done on sorting it out! Thanks for posting your solution.

    @soetie,

    You’ll need to setup your SMTP settings for Send-MailMessage and set the UseSsl property up to $true (as gmail requires a secure connection to send mail). There are a bunch of blog posts around online that show how to send an email with gmail in PowerShell – try google or here is a blog post that after a quick glance seems to show its use correctly with gmail: http://www.adminarsenal.com/admin-arsenal-blog/powershell-sending-email-with-gmail-example

    Don’t forget to specify custom port number for sending either (based on what gmail requires).

    Hope that helps.

    Sean

  • Geoffj981

    All event logs for the day
    This script is awesome and exactly what I’ve been looking for. Is there anyway to have it list all the events for the current day that generated errors?

  • Geoffj981

    All event logs for the day
    This script is awesome and exactly what I’ve been looking for. Is there anyway to have it list all the events for the current day that generated errors?

  • Geoffj981

    All event logs for the day
    This script is awesome and exactly what I’ve been looking for. Is there anyway to have it list all the events for the current day that generated errors?

  • Geoffj981

    All event logs for the day
    This script is awesome and exactly what I’ve been looking for. Is there anyway to have it list all the events for the current day that generated errors?

  • Geoffj981

    All event logs for the day
    This script is awesome and exactly what I’ve been looking for. Is there anyway to have it list all the events for the current day that generated errors?

  • testerindia25

    Error
    Hi Sean

    Good Script

    I am getting below error while running the script.Can you please suggest any changes

    Get-Content : Cannot bind argument to parameter ‘Path’ because it is null.
    At C:UsersputtagraDesktopsql.ps1:10 char:26
    + $computers = get-content $list #grab the names of the servers/computers to check …
    + ~~~~~
    + CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentCommand

    Send-MailMessage : Cannot validate argument on parameter ‘Attachments’. The argument is null, empty, or an element of the argument
    collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
    At C:UsersputtagraDesktopsql.ps1:289 char:85
    + … " -Attachments $ListOfAttachments -BodyAsHTML -body $HTMLmessage -priority Norma …
    + ~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Send-MailMessage], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.SendMailMessage

  • Shogan

    RE: testerindia25
    Hi testerindia25,

    It seems as though the script is struggling to get a handle on your text file listing the computers/servers that the script uses to query.

    I would check how you are starting the script, and ensure that the path it is getting passed is valid (and points to your text file). If there are spaces in your folder structure, try removing those as a start (for example place your file in C:tempcomputerlist.txt and try that.

    Also remember to call the script and pass it the path to your text file. For example: .sql.ps1 c:tempcomputerlist.txt

    Hope that helps!
    Sean

  • zerocool18

    Optimised with Remoting link
    I forgot to share the optimised version. Please get it here
    http://powershelldiaries.blogspot.in/2015/03/my-biggest-contribution-yet-system.html

    please try to add these features in script :

    ## Currently logged-in users
    ## Userswho have access to servers but are not in our TRUST list
    ## Pending Patches / Windows Updates
    ## Color Highlight Low-Disk Space warnings in email report

  • Wasantha

    Send Reminder to Distribution Exchange -2010
    Hi, I have to send remind to one Distribution group. i create following script, but it not working. can you pls help for this…

    #$filename = “Desktopbackupzdrive.jpg”
    $Server = “mailservername”
    #$emailSmtpServerPort = "587"

    $att = new-object Net.Mail.Attachment("DesktopbackupZ_Drive.jpg")
    $msg = new-object Net.Mail.MailMessage
    #$att = new-object Net.Mail.Attachment($filename)
    $smtp = new-object Net.Mail.SmtpClient($Server)
    $att.ContentId = "att"
    $msg.From = "System Administrator< Administrator@domain>"
    $msg.bcc.Add(”GroupName@”)
    $msg.Subject = “Reminder! Your computer is not backed up ,Backup your files today !!!”
    $msg.IsBodyHTML = $true

    #Common HTML head and styles
    $htmlhead="<html>
    <style>
    BODY{font-family: Calibri; font-size: 12pt;}
    #BODY {background-color:#D7D8D8;}

    </style>
    <body>"

    #Summarise databases with Alert status

    $alertintro = "<p>Dear All,</p>"

    #Summarise databases with OK status

    $okintro = "<p> Please use your maped network drive (Z:) to save your important files, as this drive is backed up onto tape each night. Backing up your data is extremely important and should be done regularly. As the owners of a laptop, you are responsible for your own data. If there is a catastrophic failure in your laptop, or you make a serious mistake, you could lose everything if you don’t keep gular backups.</p>"

    $intro = "<p>Backing up your important data is not very hard, it just takes a few minutes of simple work.</p>"

    $summary = "<p>Please do not hesitate to contact IT Division if you have any further questions or concerns regarding this.</p>"

    $outro = "<p>Thanks</p>"
    $outro1 = "<p>Regards </p>"
    $outro2 = "<p>TI Division </p>"
    $outro3 = "<p>Ex: <br><img src=’cid:att’ /></p>"

    $htmltail="</body>
    </html>"

    #Get ready to send email message

    $htmlreport = $htmlhead +$alertintro + $okintro +$intro +$summary+ $outro+$outro1+$outro2+$outro3+ $htmltail

    $msg.body = $htmlreport

    $msg.Priority = [System.Net.Mail.MailPriority]::High

    $msg.Attachments.Add($att)

    $SMTPClient = New-Object System.Net.Mail.SmtpClient($Server)
    $SMTPClient.UseDefaultCredentials=$true
    #$SMTPClient.EnableSsl = $true
    #$SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass );

    $SMTPClient.Send($msg)

    $att.Dispose()

  • Wasantha

    Send Reminder to Distribution Exchange -2010
    Hi, I have to send remind to one Distribution group. i create following script, but it not working. can you pls help for this…

    #$filename = “Desktopbackupzdrive.jpg”
    $Server = “mailservername”
    #$emailSmtpServerPort = "587"

    $att = new-object Net.Mail.Attachment("DesktopbackupZ_Drive.jpg")
    $msg = new-object Net.Mail.MailMessage
    #$att = new-object Net.Mail.Attachment($filename)
    $smtp = new-object Net.Mail.SmtpClient($Server)
    $att.ContentId = "att"
    $msg.From = "System Administrator< Administrator@domain>"
    $msg.bcc.Add(”GroupName@”)
    $msg.Subject = “Reminder! Your computer is not backed up ,Backup your files today !!!”
    $msg.IsBodyHTML = $true

    #Common HTML head and styles
    $htmlhead="<html>
    <style>
    BODY{font-family: Calibri; font-size: 12pt;}
    #BODY {background-color:#D7D8D8;}

    </style>
    <body>"

    #Summarise databases with Alert status

    $alertintro = "<p>Dear All,</p>"

    #Summarise databases with OK status

    $okintro = "<p> Please use your maped network drive (Z:) to save your important files, as this drive is backed up onto tape each night. Backing up your data is extremely important and should be done regularly. As the owners of a laptop, you are responsible for your own data. If there is a catastrophic failure in your laptop, or you make a serious mistake, you could lose everything if you don’t keep gular backups.</p>"

    $intro = "<p>Backing up your important data is not very hard, it just takes a few minutes of simple work.</p>"

    $summary = "<p>Please do not hesitate to contact IT Division if you have any further questions or concerns regarding this.</p>"

    $outro = "<p>Thanks</p>"
    $outro1 = "<p>Regards </p>"
    $outro2 = "<p>TI Division </p>"
    $outro3 = "<p>Ex: <br><img src=’cid:att’ /></p>"

    $htmltail="</body>
    </html>"

    #Get ready to send email message

    $htmlreport = $htmlhead +$alertintro + $okintro +$intro +$summary+ $outro+$outro1+$outro2+$outro3+ $htmltail

    $msg.body = $htmlreport

    $msg.Priority = [System.Net.Mail.MailPriority]::High

    $msg.Attachments.Add($att)

    $SMTPClient = New-Object System.Net.Mail.SmtpClient($Server)
    $SMTPClient.UseDefaultCredentials=$true
    #$SMTPClient.EnableSsl = $true
    #$SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass );

    $SMTPClient.Send($msg)

    $att.Dispose()

  • Axle 108

    Extending the script
    Love the script and have added some tweaks to it that I will share.

    I have added Security logs so I can see if there has been any failed log ins Notice I have limited it to collect events from the last 24 hrs.

    $SecurityEventsReport = @()
    $SecurityEvents = Get-EventLog -ComputerName $computer -LogName Security -EntryType FailureAudit -Newest $EventNum -after ((get-date).addDays(-1))
    foreach ($event in $SecurityEvents) {
    $row = New-Object -Type PSObject -Property @{
    TimeGenerated = $event.TimeGenerated
    EntryType = $event.EntryType
    Source = $event.Source
    Message = $event.Message
    }
    $SecurityEventsReport += $row
    }

    $SecurityEventsReport = $SecurityEventsReport | ConvertTo-Html -Fragment

    <p>The following is a list of the last $EventNum <b>Security log</b> events that had an Event Type of either Warning or Error on $computer</p>
    <table class="normal">$SecurityEventsReport</table>

    I would like to add get the last windows update using Get-hotfix powershell command. But I am not a html or powershell guru.

  • Shogan

    Extending the script
    Hi @Axle 108,

    Thanks for contributing! It really is great to see everyone’s additions here in the comments.

    Have you ever tried using a gist to share scripts? https://gist.github.com – you can paste your code there, then link it here in a comment and the script will be displayed nicely formatted with indentations etc on the Gist page. Something to check out in future!

    Thanks for your script 🙂

    Sean

  • aussiegeek

    Trouble running script
    Hi Can someone please help me run this script. It needs to run with the get-content and $list variable as stated in the script however I just can’t get it to work. Would be great if any of you keen powershellers could help me with a couple of lines. It would be so greatly appreciated!

  • Axle 108

    Trouble running script
    Hi aussiegeek

    If I understand, you are just attempting to run the script.

    Ok If you want to run the script from a scheduled task I have created a batch file with one line. Don’t forget you need to create the list.txt file with each server name on a new line.

    https://gist.github.com/a627323160eea32e74d6.git

  • Axle 108

    Trouble running script
    Sorry I don’t think the link worked.
    <script src="https://gist.github.com/anonymous/0e2da15db011a4a8278d.js"></script&gt;

  • Axle 108

    Trouble running script
    Arrrrgggggg ok just going to past the line in the blog sorry Shogen.

    Powershell.exe -executionpolicy bypass ".SystemsReport.ps1 ‘.list.txt’"

  • aussiegeek

    Thank you!
    Thanks Axle.. Much appreciated!
    So simple!

  • weiyentan

    Creating a report for an individual server
    Geat script! I was wondering whether we could create individual report per computer?

    I figure there would be an extra loop to get the system to create the report but I am unsure of what the layout will look…

    Any help appreciated.

  • cat65

    Running Script without text file
    Sean,
    I must say your script works great! I would like to run the script against single, remote servers, not using the list.txt file. Something like SystemsReport <servername> What would I need to change? I am very new to powershell. Thank you.

  • Shogan

    cat65
    Hi cat65,

    Great. Simple to do what you want really. At the very top of the script simply:

    Comment out this line: $list = $args[0]
    Comment out this line: get-content $list

    and in-place of the second line you commented out (get-content $list), put this line:

    $computers = $args[0]

    Now, whatever you pass into the script as the first argument, becomes your $computers variable. So you could now do:

    .SystemsReport.ps1 "MyRemoteServerName"

    or fancier, you could pass in a list of machines directly as an array:

    .SystemsReport.ps1 @("MyRemoteServerName1","MyRemoteServerName2","MyRemoteServerName3")

    Hope that helps!

    Cheers,
    Sean

  • cat65

    Running Script without text file
    Thank you for the speedy reply!! That is perfect. I do have one other problem in that I can’t run the script against remote servers. I am getting error:
    Get-WMIObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At C:scriptsSystemsReport.ps1:146 char:13
    + $DiskInfo= Get-WMIObject -ComputerName $computer Win32_LogicalDisk | Where-Obje …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At C:scriptsSystemsReport.ps1:150 char:9
    + $OS = (Get-WmiObject Win32_OperatingSystem -computername $computer).caption

    I have tried different execution policy levels and some wmi commands without any luck.

    Thank you very much.

  • Shogan

    cat65
    Hmmm,

    That seems like you’ve got a comms issue from your workstation to the remote machine over RPC. Try run the script on your local machine and check that that works. E.g.

    .SystemsReport.ps1 localhost

    You’ll probably find its fine, and your remote machines are not allowing the WMI cmdlets to be run remotely. Either a firewall issue or RPC / WMI connections are not allowed remotely on those machines. You’ll need to troubleshoot that separately unfortunately. Try google that error message and look up allowing remote WMI / RPC.

    Good luck!

  • iammine843

    Awesome Script!
    Awesome script. I had one similar but it exported to an excel file. I don’t know HTML so this is awesome!

    So I modified the script a little and have it outputting to an HTML file. However, instead of the HTML file being one continious file, I want a seperate file for each server I run through the loop.

    I thought I had it by changing the output to

    $CurrentsystemHTML | Out-File $Outputfile

    However, when I do that, I lose the HTML Formating of the full report.

    How would I make it so that each server in the loop out output to a file?

    Thanks Again!

  • mastrosky

    cross domain
    How do I get it to look at servers in another domain from the one I log into? We have the permission but I would like to specify domain and user credentials. Newbie here and not even good enough to call myself a novice yet.

    thanks

  • zerocool18

    New Version with Remoting on GitHub
    https://rahulduggal18.github.io/PS-Scripts/

  • Shogan

    RE: New Version with Remoting on GitHub
    Nice work! This looks great. Thanks for updating to use PS Remoting and for adding the error handling.

  • Matthew Quickenden

    Here is a link to post about an HTML reporting module. It’s a series of functions that help generate HTML code easily from within your powershell scripts. I am actually working to clean up the a Pie chart function for it as well.

    http://www.azurefieldnotes.com/2016/08/04/powershellhtmlreportingpart1/

    • Matthew Quickenden

      I recreated a version of this report using the ReportHTML Module and added some more charts. There is a screen shot preview at the bottom of this blog post http://www.azurefieldnotes.com/2016/08/30/more-html-reporting-in-powershell-part-5/. This was more an exercise to show what can be done with the module and how easy it is to create reports and show the images are embedded as base64. Thanks for sharing your scripts.

      Sample Report
      https://azurefieldnotesblog.blob.core.windows.net/wp-content/ACESystemsReport-SystemsReport.mht

      PowerShell Code
      https://github.com/azurefieldnotes/ReportHTML/blob/master/Examples/Run-SystemsReport.ps1

      • Ilya Kolodiychik

        Matthew, your code link doesn’t seem to be working.

        That being said, I like the screenshot. Any idea if it’s possible to get a single report with x number of servers CPU/RAM listed? I’m basically looking to run a PS query against all the servers (30) in an environment and getting the CPU/RAM stats for the last 12 or 24hrs in a nice graph and have it emailed to me. I know I can do this via PerfMon but I then need to post process, etc. and send out the email manually to make it readable (PerfMon creates a numbers only CSV).

        • Matthew Quickenden

          I moved the report to a separate project, hopefully this link works. https://github.com/azurefieldnotes/Reports/blob/master/Run-SystemsReport.ps1
          I also made some changes, added a summary section and edited this report to use a sample of the local machine 3 times. This is an example and does need additional work but hopefully its a pretty good start. For CPU and RAM you many want to edit the SystemInfo WMI query to capture the information you’re after and perhaps create and array to collect the data and display it in the summary section at the end of the report. I am a little swamped to work on it anymore at the moment. Hope this helps.

          • Ilya Kolodiychik

            Thanks Matthew. I’ll tinker around with it and hopefully I can get it to work :).

  • Ilya Kolodiychik

    Hi…any idea why when I run this it just keeps appending? I want a brand new file each time.

    I’ve changed the following, but still no luck:

    $HTMLmessage | Out-File C:ServerPerformanceReportsTest_$CurrentTime.htm -Force

  • Jheremy

    Hi, I’m using this script and this perfect, but now I am running from a server where SMTP is Gmail and asks me username and password, I tried to modify the script to work and have not been successful, anyone knows how? (Excuse my bad English)

  • Karen woodwell

    Hi, I’m very new at Powershell but, quite interested. I love these reports!!! But, we need an automatic report on our deployments go out and updating us on the percentages successes and fails. Pie charts too that would be great… I know I’m asking alot. I’ve been looking for something that would send a text from SCCM 2012r2 but, I don’t think that technology is there, yet. the report that we use is Software Distribution- Application monitoring. Could you help us with this?? I know we could subscription but, we setup our deployments at mid-of the night or morning due to we work in the hospital and need to report back to a Project Manager with the results. Let me know your thoughts, I would be interest. Thank you.