Indyrb
asked on
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?
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?
ASKER
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.
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.
Do you use the same active directory domain or are they all their own AD domains?
ASKER
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.
The script you're looking for is not a simple script and would require you to understand the scripting language and build/troubleshoot.
ASKER
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.
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.
ASKER
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.cs v")
[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.Director ySearcher( $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).operatingsyste m | 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.SerialNumb er = ($Win32_BIOS.SerialNumber)
if ($($ComputerSystem.SerialN umber) -notmatch "^VMware") {
$ComputerSystem.BIOS_Versi on = ($Win32_BIOS.SMBIOSBIOSVer sion)
$ComputerSystem.Name = ($Win32_ComputerSystem.Nam e)
$ComputerSystem.Manufactur e = ($Win32_ComputerSystem.Man ufacturer)
$ComputerSystem.Model = ($Win32_ComputerSystem.Mod el)
$ComputerSystem.PhysicalMe moryGB = (($Win32_ComputerSystem.To talPhysica lMemory)/1 GB -as [int])
$OperatingSystem = (Get-WmiObject -computername $Computer -Class Win32_OperatingSystem) #class
$ComputerSystem.OS = ($OperatingSystem.Name.spl it("|").Ge t(0))
$ComputerSystem.SP = ($OperatingSystem.CSDVersi on)
$Win32_Processor = (Get-WmiObject -ComputerName $Computer -Class Win32_Processor) #class
foreach ($processor in $Win32_Processor) {
$ComputerSystem.NumberOfPh ysicalCPUs = ($Win32_Processor | measure | select -exp count)
$ComputerSystem.NumberOfCo resPerCPU = 0
$ComputerSystem.NumberOfCo resPerCPU = ($processor.NumberOfCores)
if(!($ComputerSystem.Numbe rOfCoresPe rCPU)) {$ComputerSystem.NumberOfC oresPerCPU = 1}
$ComputerSystem.ProcessorD escription = ($processor.Description)
$ComputerSystem.ProcessorS peedGHz = (($processor.MaxClockSpeed )/1000)
if ($ComputerSystem.SerialNum ber -notmatch "^VMWare") {$ComputerSystem.Type = "Physical"} else {$ComputerSystem.Type = "Virtual"}
}
Add-content $X "$($ComputerSystem.Name),$ ($Computer System.Typ e),$($Comp uterSystem .SerialNum ber),$($Co mputerSyst em.OS),$($ ComputerSy stem.SP),$ ($Computer System.Man ufacture), $($Compute rSystem.Mo del),$($Co mputerSyst em.BIOS_Ve rsion),$($ ComputerSy stem.Physi calMemoryG B),$($Comp uterSystem .NumberOfP hysicalCPU s),$($Comp uterSystem .NumberOfC oresPerCPU ),$($Compu terSystem. ProcessorD escription ),$($Compu terSystem. ProcessorS peedGHz)" | 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 ***"
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.cs
[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"
$searcher = New-Object DirectoryServices.Director
$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).operatingsyste
}
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.SerialNumb
if ($($ComputerSystem.SerialN
$ComputerSystem.BIOS_Versi
$ComputerSystem.Name = ($Win32_ComputerSystem.Nam
$ComputerSystem.Manufactur
$ComputerSystem.Model = ($Win32_ComputerSystem.Mod
$ComputerSystem.PhysicalMe
$OperatingSystem = (Get-WmiObject -computername $Computer -Class Win32_OperatingSystem) #class
$ComputerSystem.OS = ($OperatingSystem.Name.spl
$ComputerSystem.SP = ($OperatingSystem.CSDVersi
$Win32_Processor = (Get-WmiObject -ComputerName $Computer -Class Win32_Processor) #class
foreach ($processor in $Win32_Processor) {
$ComputerSystem.NumberOfPh
$ComputerSystem.NumberOfCo
$ComputerSystem.NumberOfCo
if(!($ComputerSystem.Numbe
$ComputerSystem.ProcessorD
$ComputerSystem.ProcessorS
if ($ComputerSystem.SerialNum
}
Add-content $X "$($ComputerSystem.Name),$
}
}
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 ***"
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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,
ValueFromPipelineByPropert yName=$Tru e)]
[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.serialn umber;
'BIOSManufacturer'=$bios.m anufacture r;
'OSVersion'=$os.caption;
'OSBuild'=$os.buildnumber;
'SPVersion'=$os.servicepac kmajorvers ion;
'OSArch'=$os.osarchitectur e;
'ProcArch'=$proc.addresswi dth;
'Ram'=$comp.totalphysicalm emory
}
$obj = New-Object -TypeName PSObject -Property $hash
Write-Output $obj
}
}
}
}
get-serverinfo localhost only shows the orginal6-7 things
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,
ValueFromPipelineByPropert
[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.serialn
'BIOSManufacturer'=$bios.m
'OSVersion'=$os.caption;
'OSBuild'=$os.buildnumber;
'SPVersion'=$os.servicepac
'OSArch'=$os.osarchitectur
'ProcArch'=$proc.addresswi
'Ram'=$comp.totalphysicalm
}
$obj = New-Object -TypeName PSObject -Property $hash
Write-Output $obj
}
}
}
}
get-serverinfo localhost only shows the orginal6-7 things
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?