Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180329

Inventory script for ESX host

$
0
0

Hi,

 

im trying to make some simple inventory script for ESX host, which would give me all information i need, but im failing to get snmp community.

 

report_hosts = Foreach($vc in $global:DefaultVIServers){

Get-VMHost | Sort Name | %{$VMHost = $_; $VMHost | Get-View | Select @{N=”ESXi Host Name”;E={$VMHost.Name}},

@{N=”name”;E={$VMHost.NetworkInfo.HostName}},

@{N=”cluster”;E={$VMHost.Parent.Name}},

@{N=”platform”;E={'VMware ESXi ' + $VMHost.Version}},

@{N='manufacturer';E={$_.Summary.Hardware.Vendor}},

@{N="model_name";E={$_.Hardware.SystemInfo.Model}},

@{N="cf_cpu_model";E={$_.Hardware.CpuPkg[0].Description}},

@{N="cf_cpu_mhz";E={[math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},

@{N="cf_cpu_count";E={$_.Hardware.CpuInfo.NumCpuPackages}},

@{N="cf_cpu_cores_per_cpu";E={($_.Hardware.CpuInfo.NumCpuCores) /($_.Hardware.CpuInfo.NumCpuPackages)}},

@{N="cf_cpu_count_threads";E={$_.Hardware.CpuInfo.NumCpuThreads}},

@{N="cf_mem_size";E={"" + [math]::round($_.Hardware.MemorySize / 1MB, 0)}},

@{N="cf_srv_uptime";E={[math]::round($_.Summary.QuickStats.uptime / 86400, 0)}}, ## figure out how to attach also text "Days" to this

@{N="serial";E={($VMHost | Get-VMHostHardware).SerialNumber}},

@{N=”NTP”;E={Get-VMHostNtpServer $VMHost}},

@{N="status"; E={$VMHost.State}},

@{N=”cf_srv_timezone”;E={$VMHost.Timezone}},

@{N=”cf_nic_count”;E={$_.Summary.Hardware.numNics}},

@{N=”cf_srv_domain”;E={($VMHost | Get-VMHostNetwork).DomainName}},

@{N="srv_uuid";E={$_.hardware.systeminfo.uuid}}

@{N="device_role"; E={'ESXi'}},

@{N="asset_tag"; E={'vcenter_sync'}},

@{N=”Datacenter”;E={$VMHost.Parent.ParentFolder.Parent.Name}}

$esxcli = Get-EsxCli -VMHost $VMHost

$esxcli.system.snmp.get() | Select @{N="communities";E={[string]::Join(",",$_.communities)}}

}

}

$report_hosts | Export-Csv C:\Temp\ESX_Devices.csv

 

All is working, except the snmp community, i would welcome any help/hints how to include the snmp into this script


Viewing all articles
Browse latest Browse all 180329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>