Collect-ServerInfo.ps1 – A PowerShell Script for Windows Server Inventory

Many of the customer projects I work on involve collecting an inventory of basic information about the Windows Servers in the environment, such as CPU/memory specs, OS versions, volume sizes, and so on.

To make this inventory process less time consuming I began using PowerShell scripts to collect the information I was interested. Over time these scripts got less messy and more useful, so now I want to share my current script.

This PowerShell script, Collect-ServerInfo.ps1, will collect information from Windows Servers that includes:

  • Computer system information (name, make, model, processor, memory, domain)
  • Operating system information (OS name, version, install date)
  • Memory information (capacity, modules, speed)
  • Pagefile information (size, location)
  • BIOS information (manufacturer, version, release date)
  • Logical disk information
  • Volume information
  • Network interface information
  • Software information

The information is output to a HTML file per server.

collect-serverinfo-report-example

Usage Examples

Collect information about a single server named SERVER1.

.\Collect-ServerInfo.ps1 SERVER1

Collect information about multiple servers.

"SERVER1","SERVER2","SERVER3" | .\Collect-ServerInfo.ps1

Collects information about all servers in Active Directory.

Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"} | %{.\Collect-ServerInfo.ps1 $_.DNSHostName}

Download

Collect-ServerInfo.ps1 can be downloaded from Github. Questions and comments are welcome below.

By Paul Cunningham

Paul is a writer and entrepreneur living in Brisbane, Australia. He enjoys spending time with his family and running in the mountains. Paul was the founder of Practical 365, a former Microsoft MVP, and Pluralsight trainer. Paul is also on Twitter and Instagram.

29 comments

  1. Awesome inventory script. Just what I needed.
    Is there a way to set this to run via Task Scheduler? The problem I’m having is the syntax – how to correctly type in all of the server-names. can you help!?? Many Thanks. Keep up the great work!

    1. Hi Brando,
      I’m using this great script but I was not able to pipe everything in a single command. I did a cmd (for task scheduling) like this
      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command “. C:\Reports\ServerInfo\callTO.ps1
      and callTO.ps1 is done as follows:
      Get-ADComputer -Filter * -searchbase “OU=xxx,DC=yy,DC=kkkk,DC=zz” -server “FQDN_DC” | %{.\Collect-ServerInfoTO.ps1 $_.DNSHostName}

      Regards.
      Red,

  2. Hi Paul,
    great work (as usual) and tnx fo sharing.
    The script generates an error against 2k3 servers
    WARNING: Invalid class “Win32_Product”

    Regards.

    Red.

        1. Hi Paul,
          I understand. As a suggestion, it wold be nice to have your script running with runspaces (or jobs) to process a lot of server with multithreading. Please, have a look at Rayan’s blog if interested
          http://www.get-blog.com/?p=189
          I tryed to integrate your work whit his but it’s to difficult for me.
          Anyway, having improved performance in parsing 1000 servers it would be great.
          Thank you.
          Red.

  3. Paul,

    Thanks for the script. Its just what I was looking for. The only think I am missing is the installed Roles and Features on a server.
    Further It would be great if your script could combine all the info in one single HTML file instead of seperate files.

    Is this doable for you to alter the script for that?

  4. Hi Paul

    Amazing scipt! just saved me a bunch of time!!

    You dont happen to know way of collecting server roles and features? :)

    Cheers

    Darren

  5. Great script. I have a problem with several of the servers that I have run this against. I get either
    Warning: Invalid Query or Warning: Quota Violation or Warning: Provider load failure.

    All of these servers that I have run your script against are Windows Server 2008 SP2. Can you shed any light on what I may be able to do to resolve this?

    1. There’s lots of results in google for quota violation errors when using Get-WMIObject, but I couldn’t say exactly why it’s happening in your case. Maybe start there.

  6. Hello Paul, It is a wonderful script and made my life very easy. thanks for that. Is it possible to export the details in excel for multiple computer ? if possible. THanks in advance.

    1. There’s a lot of variation in the data, for example one server might have a single IP addresses, whereas another server might have 8 IP addresses. Or 2 memory slots vs 4 memory slots. And so on. So getting a consistent structure into Excel seems like it would be very challenging.

      1. I can able to import this data into excel but the data was importing in row format i am looking this data can be converted to column wise is there any solution for it ?.

  7. This is pretty awesome. It would be fantastic if there was a simple way to have the script build a general info or index page. For example Windows 10 system I 43, (link to systems) Manufacturer HP x 45 (link to all hp systems) etc….

  8. Note sure what I’m doing wrong, but I get an error when trying to run this. I’ve tried the above three examples. Running on a 2008R2 DC

    PS C:\Users\Jimmy\desktop> .\Collect-ServerInfo.ps1 “sirius”,”rigel”,”betelgeuse”
    Missing or invalid array index expression.
    At C:\Users\Jimmy\desktop\Collect-ServerInfo.ps1:25 char:50
    + if (!($PSCmdlet.MyInvocation.BoundParameters[ <<<< â?oVerboseâ??].IsPresent))
    + CategoryInfo : ParserError: ([:String) [], ParseException
    + FullyQualifiedErrorId : MissingArrayIndexExpression

    Missing or invalid array index expression.
    At C:\Users\Jimmy\desktop\Collect-ServerInfo.ps1:25 char:50
    + if (!($PSCmdlet.MyInvocation.BoundParameters[ <<<< â?oVerboseâ??].IsPresent))
    + CategoryInfo : ParserError: ([:String) [], ParseException
    + FullyQualifiedErrorId : MissingArrayIndexExpression

    Missing or invalid array index expression.
    At C:\Users\Jimmy\desktop\Collect-ServerInfo.ps1:25 char:50
    + if (!($PSCmdlet.MyInvocation.BoundParameters[ <<<< â?oVerboseâ??].IsPresent))
    + CategoryInfo : ParserError: ([:String) [], ParseException
    + FullyQualifiedErrorId : MissingArrayIndexExpression

    1. PS C:\Users\Jimmy\desktop> .\Collect-ServerInfo.ps1 “sirius”,”rigel”,”betelgeuse”

      I don’t think that will work. What happens when you use the example syntax from the blog post?

  9. Hi Paul,

    Great work.

    However, warning around using Win32_Product WMI class.

    Lots of information on the net about why to not use this class.

    Use StdRegProv class to read the software installs from the Registry instead.

    Thanks

  10. Hello,

    It’s grate script it solved my most needs but can we convert this data to Excel format?

    Could you please help one this.

    Thanks
    Vamsi

  11. Hi,

    I need to provide Admin credentials to login multiple servers in this script. Could you please help me where can I add that details in the script?

  12. i am getting below given error. kindly help. also do you have any script which let me know services and roles installed o running on it.

  13. Hi Paul,

    Amazing script, could you advise on how we can pass a list of servers, like from a text file or csv instead of typing every single system name.

    All the options you have provided worked fine for me.

    1. Nevermind, figured it out :) for others who might want the same thing

      >Get-Content “/.txt” | .\Collect-ServerInfo.ps1

      This should get you running the above script with the list of computer names saved in a text file.

      Still helping out people in 2019 :)

Comments are closed.