Why I no longer hate writing documentation…
…it’s because I no longer have to! And you too will no longer document your computers and servers either. Why? Because PowerShell is going to do it for you and I’m going to share with you how I did it. Yes, it is going to be presented well, in Excel, and the Boss is going to think that you are the greatest thing since sliced bread.
Computer Inventory
I picked up a side job at the beginning of the year documenting the infrastructure for a company that will remain anonymous at this time. It doesn’t surprise me that many companies still do not maintain up-to-date documentation if any. What is the “BIG DEAL” about documenting a system, is it really a “time factor” problem or “lack of resources” to do the job? I, like many of my peers, just think documenting SUCKS!!! So I set out to make my life and hopefully yours a little easier.
The Computer Inventory Script enumerates Hardware, OS, System, Processor, Memory, Disk, and Network information and neatly organizes it in an Excel file. I’ve provided Version 2 of the script that allows you to choose a number of computer resources; all computers in the domain, all servers in the domain, computers from a list maintained in a text file, and the ability manually pick a computer. Version 2 of the PowerShell script also allows you to send credential information should you wish to logon the remote computer with an alternative user account. This is helpful for DMZ servers as well as stand alone servers that are not members of your domain.
Please feel free to customize this script to fit your environment. I’m not going into any detail about the script as I am reserving that information for a new PowerShell tutorial that I am writing about COM objects. So check the tutorial section to for more information.
Here is the code so that you can view it before downloading. I would suggest downloading this file as format issues with copying the code below may occur.
Email This Post To A Friend
« Conficker Worm Detection | Home | How do I know if I’m missing MS Patches? »






Comments
Wow! What a great script! Just ran it for the first time. The way the results are capture in Excel is impressive.
Thanks, this helps a lot!!!
Love it. Unfortunately I can’t get it to work with Office 2007.
It just starts Excel, doesn’t create a sheet with information.
For the record I am using Office 2003. I’ll get a copy of Excel 2007 and test the code…
Tested script with Excel 2007 and it works. It may be the option you are choosing. If you are choosing the option to gather info from “All Computers” or “All Servers” in your domain, it may take a long time to enumerate all the information. Try Option [4]Choose a Computer manually to test enumerating from a single computer.
DUDE!!! This is the best! The memory sheet is my favorite love that I can see the number of slots, what size RAM is installed, and which slots are empty. Makes memory upgrades much easier without having to power down and opening the box.
Hmm ok, that’s what I tried. Will make it run a bit longer and see.
The problem with empty Excel is with the current locale. Set current locale to “en-US” and it will work.
Would it be possible to add a software installed tab.
Hi there..
I been trying to find the Set current locale to “en-US” and tried replacing the code however no luck and help would be appreciated
#New Excel Application
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
with
$ci = new-object globalization.cultureinfo en-US
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel.UserControl= $True
$Sheet = $Excel.Workbooks
$Sheet.PSBase.GetType().InvokeMember(”Add”,
[reflection.bindingflags]::InvokeMethod,$null, $Sheet, $null, $ci)
I added this function
# ========================================================================
# Function Name Select-FileDialog #
# Created by Hugo Peeters #
# http://www.peetersonline.nl #
###############################
# Example use:
# $file = Select-FileDialog -Title “Select a file” -Directory “D:\scripts” -Filter “Powershell Scripts|(*.ps1)”
function Select-FileDialog
{
param([string]$Title,[string]$Directory,[string]$Filter=”All Files (*.*)|*.*”)
[System.Reflection.Assembly]::LoadWithPartialName(”System.Windows.Forms”) | Out-Null
$objForm = New-Object System.Windows.Forms.OpenFileDialog
$objForm.InitialDirectory = $Directory
$objForm.Filter = $Filter
$objForm.Title = $Title
$Show = $objForm.ShowDialog()
If ($Show -eq “OK”)
{
Return $objForm.FileName
}
Else
{
Write-Error “Operation cancelled by user.”
}
}
# ==============================================================================================
And changed the line
$strText = Read-Host “Enter the path for the text file”
To
$strText = Select-FileDialog -Title “Select a file” -Directory “c:” -Filter “Text Files (*.txt)|*.txt”
now I can browse to select the text file of computers.
I get an error when excel opens too..
Which computer resources would you like in the report?
Exception calling “Add” with “0″ argument(s): “Old format or invalid type library. (Exception from HRESULT: 0×80028018 (TYPE_E_INVDATAREAD))”
At :line:390 char:29
+ $Excel = $Excel.Workbooks.Add <<<< ()
can someone send me final version of this script, I cannot configure it to run with excel 2007.
matiss(dot)baltalksnis@gmail.com
This script is great but i am new to powershell and need the uptime of the servers added to this script, how to do that????
Hi, How do I change this script to output to notepad, we do not have Excel?
Thanks
Can someone recomend a good book on PowerShell, for a beginner
This looks great - however when choosing option 1 for all domain computers only one machine shows up. No errors pop up but in the debug window I see the following:
“Which computer resources would you like in the report?”
Undetermined
Undetermined
Any help would be appreciated.
Thanks,
Brian
Leave a Comment