Jump to content

blazedbud

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by blazedbud

  1. This script will give you pretty much everything you need from server / computers. Let me know if you need any additional lines adding #Get the server list $servers = Get-Content C:\PATH-TO-LIST-OF-COMPUTERS-OR-SERVERS\Serverlist.txt #Run the commands for each server in the list $infoColl = @() Foreach ($s in $servers) { $CPUInfo = Get-WmiObject Win32_Processor -ComputerName $s #Get CPU Information $OSInfo = Get-WmiObject Win32_OperatingSystem -ComputerName $s #Get OS Information #System Information $Domain = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $s $ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $s #GetC Server Details - Model, etc $System = Get-WmiObject -Query "SELECT * FROM Win32_SystemEnclosure" -Namespace "root\CIMV2" -ComputerName $s #Get server serial number #Hard Drive Information #Network Information $IPAddresses = Get-WMIObject -Class Win32_NetworkAdapterConfiguration -ComputerName $s | Where-Object -FilterScript {$_.IPEnabled} | Select-Object @{Name=’IPAddress’;Expression={[string]::join(“ - ”, ($_.IpAddress))}} $DNSEntries = Get-WMIObject -Class Win32_NetworkAdapterConfiguration -ComputerName $s | Where-Object -FilterScript {$_.IPEnabled} | Select-Object @{Name=’DNS’;Expression={[string]::join(“ - ”, ($_.DNSServerSearchOrder))}} $PersitentRouteIP = Get-WMIObject -Class Win32_IP4PersistedRouteTable -ComputerName $s | Select-Object @{Name=’IPAddress’;Expression={[string]::join(“ - ”, ($_.Destination))}}, ` @{Name=’NetMask’;Expression={[string]::join(“ - ”, ($_.mask))}}, ` @{Name=’DefaultGateway’;Expression={[string]::join(“ - ”, ($_.NextHop))}} $MACAddress = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $s | Where-Object -FilterScript {$_.IPEnabled} | Select-Object @{Name=’MAC’;Expression={[string]::join(“ - ”, ($_.MacAddress))}} #Get Memory Information. The data will be shown in a table as MB, rounded to the nearest second decimal. $OSTotalVirtualMemory = [math]::round($OSInfo.TotalVirtualMemorySize / 1MB, 2) $OSTotalVisibleMemory = [math]::round(($OSInfo.TotalVisibleMemorySize / 1MB), 2) $PhysicalMemory = Get-WmiObject CIM_PhysicalMemory -ComputerName $s | Measure-Object -Property capacity -Sum | % { [Math]::Round(($_.sum / 1GB), 2) } Foreach ($CPU in $CPUInfo) { $infoObject = New-Object PSObject #The following add data to the infoObjects. Add-Member -inputObject $infoObject -memberType NoteProperty -name "ServerName" -value $CPU.SystemName Add-Member -InputObject $infoObject -MemberType NoteProperty -name "Domain" -value $Domain.domain Add-Member -InputObject $infoObject -MemberType NoteProperty -name "SerialNumber" -value $System.SerialNumber Add-Member -InputObject $infoObject -MemberType NoteProperty -name "ServerManufacturer" -value $ComputerSystem.Manufacturer Add-Member -InputObject $infoObject -MemberType NoteProperty -name "ServerModel" -value $ComputerSystem.Model Add-Member -InputObject $infoObject -MemberType NoteProperty -name "IPAdresses" -value $IPAddresses Add-Member -InputObject $infoObject -MemberType NoteProperty -name "DNSEntries" -value $DNSEntries Add-Member -InputObject $infoObject -MemberType NoteProperty -name "PersitentRouteIP" -value $PersitentRouteIP Add-Member -InputObject $infoObject -MemberType NoteProperty -name "MACAddress" -value $MACAddress Add-Member -inputObject $infoObject -memberType NoteProperty -name "Processor" -value $CPU.Name Add-Member -inputObject $infoObject -memberType NoteProperty -name "Model" -value $CPU.Description Add-Member -inputObject $infoObject -memberType NoteProperty -name "Manufacturer" -value $CPU.Manufacturer Add-Member -inputObject $infoObject -memberType NoteProperty -name "PhysicalCores" -value $CPU.NumberOfCores Add-Member -inputObject $infoObject -memberType NoteProperty -name "Sockets" -value $CPU.SocketDesignation Add-Member -inputObject $infoObject -memberType NoteProperty -name "CPUThreads" -value $CPU.NumberOfLogicalProcessors Add-Member -inputObject $infoObject -memberType NoteProperty -name "OS_Name" -value $OSInfo.Caption Add-Member -inputObject $infoObject -memberType NoteProperty -name "OS_Version" -value $OSInfo.Version Add-Member -inputObject $infoObject -memberType NoteProperty -name "TotalPhysical_Memory_GB" -value $PhysicalMemory $infoObject #Output to the screen for a visual feedback. $infoColl += $infoObject } } $infoColl | Export-Csv -path C:\PATH-TO-CSV-OUTPUT-FILE\ServerInventory_$((Get-Date).ToString('MM-dd-yyyy')).csv -NoTypeInformation #Export the results in csv file.
×
×
  • Create New...