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?
LVL 5
IndyrbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

piattndCommented:
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?
0
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.
0
piattndCommented:
Do you use the same active directory domain or are they all their own AD domains?
0
Redefine Your Security with AI & Machine Learning

The implications of AI and machine learning in cyber security are massive and constantly growing, creating both efficiencies and new challenges across the board. Check out our on-demand webinar to learn more about how AI can help your organization!

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
0
piattndCommented:
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.
0
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.
0
IndyrbAuthor Commented:
I came across this powershell script...
Can someone help me add device id c:\ disk size, free space and used space
pagefile
Ip address , subnet, default gateway, primarydns, secondarydns



param($X="C:\powershell.csv")

      [array]$Servers=@()
      [array]$array1 = @()

      cls

      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
      $searcher.findall()
      }
      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 ***"
0
btanExec ConsultantCommented:
0
Rich RumbleSecurity SamuraiCommented:
http://code.google.com/p/avarice-nms/source/browse/trunk/avarice-nms/scripts/inventory-2.0.vbs
Use multi-thread.vbs to get all your domain as fast as you can
http://code.google.com/p/avarice-nms/source/browse/trunk/avarice-nms/scripts/multithread.vbs

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.
-rich
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 = @{
'example'=$xyz.variable;

isn't showing up

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$True,
                   ValueFromPipeline=$True,
                   ValueFromPipelineByPropertyName=$True)]
        [Alias('name')]
        [string[]]$computername,
        [string]$logfile = 'failed.txt'
    )
    BEGIN {
        Del $logfile -ea SilentlyContinue
    }
    PROCESS {
        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 = @{
                    'ComputerName'=$computer;
                    'BIOSSerial'=$bios.serialnumber;
                              'BIOSManufacturer'=$bios.manufacturer;
                                                  'OSVersion'=$os.caption;
                    'OSBuild'=$os.buildnumber;
                    'SPVersion'=$os.servicepackmajorversion;
                    'OSArch'=$os.osarchitecture;
                    'ProcArch'=$proc.addresswidth;
         'Ram'=$comp.totalphysicalmemory
                }
                $obj = New-Object -TypeName PSObject -Property $hash
                Write-Output $obj
            }
        }
    }
}


get-serverinfo localhost only shows the orginal6-7 things
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.