Server inventory

I am looking for a script that will create an excel spreadsheet of all the servers in the environment

It would have
Server name:   Operating System: Manufacurer: Service Tag/Serial Number   Make and Model   IP address and if its a virtual machine or not. and also OU if in ADS.

Then also create a log of servers that are no longer available

I am hoping to get Windows , ESX, and Linux, Sun servers alike in the master spreadsheet, but not sure if that possible.

Can anyone help me get started?
Who is Participating?
That's quite the broad request there!  :)

Do you have any powershell scripting experience?  How many servers are you talking about?  Are they all on the same subnet or are they scattered across many subnets?
IndyrbAuthor Commented:
No not really
I am talking about 2000+ servers across multiple subnets and sites.

I don't even know all the subnets used, as there is not a reverse dns lookup zone for everyone used.
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

Do you use the same active directory domain or are they all their own AD domains?
IndyrbAuthor Commented:
All in same domain. Actually there is one child domain but I can do they seperately. My main goal is the root domain
Your best bet is to get the computer names from Active Directory OUs where the server computer objects are stored.  You can then use DNS to attempt to resolve the IP Address to a host name and log those to the excel spreadsheet.

The script you're looking for is not a simple script and would require you to understand the scripting language and build/troubleshoot.
IndyrbAuthor Commented:
Anybody have examples of a vbs or powershell that will export
Server name:   Operating System: Manufacurer: Service Tag/Serial Number   Make and Model   IP address and if its a virtual machine or not. and also OU if in ADS. to an excel spreadsheet.
IndyrbAuthor Commented:
I came across this powershell script...
Can someone help me add device id c:\ disk size, free space and used space
Ip address , subnet, default gateway, primarydns, secondarydns


      [array]$array1 = @()


      New-Item -ItemType File $X -force | out-Null

      Add-Content $X "Server Name,Server Type,Serial Number,OS Version,OS Service Pack,Server Manufacture,Server Model,Server BIOS Version,Physical Memory GB,Number of CPUs,Number of Cores per CPU,Processor Description,Processor Speed GHz" | out-Null

      $X1 = (($X).Split("_").Get(0)) + "_unreachable.txt"

      New-Item -ItemType File $X1 -force | out-Null
      Add-Content $X1 "Computer Name `n" | out-Null

      Write-Host "Computer Serial Numbers will be wriiten to $X `n"
      Write-Host "Unreachable Computers will be written to $X1 `n`n"

      function FindServers {
      $OUpath = "" 
      $dn = $domain.distinguishedName
      if($OUpath) {$Servers = [ADSI]"LDAP://$OUpath,$dn"} else {$Servers = [ADSI]"LDAP://$dn"}
      $searcher = New-Object DirectoryServices.DirectorySearcher($Servers)
      $searcher.filter = "(objectClass=computer)"
      $Searcher.CacheResults = $true
      $Searcher.SearchScope = "Subtree"
      $Searcher.PageSize = 100
      Write-Host "Please wait gathering computers from AD `n`n"
      $ServerList = @(FindServers)

      foreach ($item in $ServerList) {
      if(($item | select -Expand properties).operatingsystem | where {$_ -match "2000|2008|2003"}) {$array1 += (($item | select -Expand properties).cn)}


      Write-Host "Please wait gathering inventry information from computers `n"
      foreach ($Computer in $array1) {Write-Host "." -NoNewline

      try {

      $ComputerSystem = @{}
      $Win32_ComputerSystem = $Null

      $Win32_ComputerSystem = (Get-WmiObject -ComputerName $Computer -Class Win32_ComputerSystem -ErrorAction SilentlyContinue) #class
      if ($Win32_ComputerSystem) {

      $Win32_BIOS = (Get-WmiObject -ComputerName $Computer -Class Win32_BIOS) #class

      $ComputerSystem.SerialNumber = ($Win32_BIOS.SerialNumber)
      if ($($ComputerSystem.SerialNumber) -notmatch "^VMware") {

      $ComputerSystem.BIOS_Version = ($Win32_BIOS.SMBIOSBIOSVersion)

      $ComputerSystem.Name = ($Win32_ComputerSystem.Name)
      $ComputerSystem.Manufacture = ($Win32_ComputerSystem.Manufacturer)
      $ComputerSystem.Model = ($Win32_ComputerSystem.Model)
      $ComputerSystem.PhysicalMemoryGB = (($Win32_ComputerSystem.TotalPhysicalMemory)/1GB -as [int])

      $OperatingSystem = (Get-WmiObject -computername $Computer -Class Win32_OperatingSystem) #class
      $ComputerSystem.OS = ($OperatingSystem.Name.split("|").Get(0))
      $ComputerSystem.SP = ($OperatingSystem.CSDVersion)

      $Win32_Processor = (Get-WmiObject -ComputerName $Computer -Class Win32_Processor) #class

      foreach ($processor in $Win32_Processor) {
      $ComputerSystem.NumberOfPhysicalCPUs = ($Win32_Processor | measure | select -exp count)
      $ComputerSystem.NumberOfCoresPerCPU = 0
      $ComputerSystem.NumberOfCoresPerCPU = ($processor.NumberOfCores)
      if(!($ComputerSystem.NumberOfCoresPerCPU)) {$ComputerSystem.NumberOfCoresPerCPU = 1}
      $ComputerSystem.ProcessorDescription = ($processor.Description)
      $ComputerSystem.ProcessorSpeedGHz = (($processor.MaxClockSpeed)/1000)

      if ($ComputerSystem.SerialNumber -notmatch "^VMWare") {$ComputerSystem.Type = "Physical"} else {$ComputerSystem.Type = "Virtual"}
      Add-content $X "$($ComputerSystem.Name),$($ComputerSystem.Type),$($ComputerSystem.SerialNumber),$($ComputerSystem.OS),$($ComputerSystem.SP),$($ComputerSystem.Manufacture),$($ComputerSystem.Model),$($ComputerSystem.BIOS_Version),$($ComputerSystem.PhysicalMemoryGB),$($ComputerSystem.NumberOfPhysicalCPUs),$($ComputerSystem.NumberOfCoresPerCPU),$($ComputerSystem.ProcessorDescription),$($ComputerSystem.ProcessorSpeedGHz)" | Out-Null
      else {Write-Host "";"Could not reach computer $Computer , continuing to next computer";"";Add-Content $X1 $Computer}
      }catch {Write-Host "";"Could not reach computer $Computer , continuing to next computer";"";Add-Content $X1 $Computer}}
      Write-Host "*** Complete ***"
btanConnect With a Mentor Exec ConsultantCommented:
Rich RumbleConnect With a Mentor Security SamuraiCommented:
Use multi-thread.vbs to get all your domain as fast as you can

useage: cscript multithread.vbs /childscript:inventory.vbs /ldapfilter:"(&(objectClass=computer))"

Open in new window

That will work for windows, not anything else, hosts have to be pingable, it's output is XML at this time however, no Excel, csv or DB output.
IndyrbAuthor Commented:
I am trying to combine a few of the samples. but run into a few road blocks.

In the example below.

if ($continue) (
I am query different get-wmi object -class XYZ
Then in $hash = @{

isn't showing up

        [string]$logfile = 'failed.txt'
    BEGIN {
        Del $logfile -ea SilentlyContinue
        foreach ($computer in $computername) {
            $continue = $true
            try {
                $os = Get-WmiObject -class Win32_OperatingSystem `
                 -computer $computer -ea Stop
            } catch {
                $computer | out-file $logfile -append
                $continue = $false
            if ($continue) {
                        $comp = Get-WmiObject -class Win32_ComputerSystem `
                 -computername $computer
                $bios = Get-WmiObject -class Win32_BIOS `
                 -computername $computer
                        $bios2 = Get-WmiObject -class Win32_BIOS `
                 -computername $computer
                $proc = Get-WmiObject -class Win32_Processor `
                 -computername $computer | Select -first 1
                $hash = @{
                $obj = New-Object -TypeName PSObject -Property $hash
                Write-Output $obj

get-serverinfo localhost only shows the orginal6-7 things
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.