Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 175116

Help with script

$
0
0


I have started this script and I am trying to figure out method types

get-vmhost | sort name | get-view |

select name,

@{N="Datacenter";E={Get-Datacenter -VMHost $_.Name}},

@{N="Type";E={$_.hardware.systeminfo.vendor+" "+ $_.Hardware.systeminfo.model}},

@{N="CPU"; E={"PROC:" + $_.Hardware.CpuInfo.NumCPUPackages + "Cores:" +

$_.Hardware.CpuInfoNumCpuCores + "MHZ:" + [math]::round($_.Hardware.CpuInfo.Hz/1000000,0)}}

 

This part works like a charm.

 

I guess what I am trying to understand $_.hardware.systeminfo.model  I know it extracts the information I want and it is using the Typename but how does this work?

 

The next part works on its own

Get-vmhostnetworkadapter  <servername> -vmkernel | select name,ip,subnetmask

This works fine but when I try to do this I have issues.

 

get-vmhost | sort name | get-view |

select name,

@{N="NIC";E={$_.Host.Networking.Nic.HostVMKernelVirtualNicImpl.Name}},

@{N="IP";E={$_.Host.Networking.Nic.HostVMKernelVirtualNicImpl.IP}},

@{N="Subnetmask";E={$_.Host.Networking.Nic.HostVMKernelVirtualNicImpl.subnetmask}}

 

This is the type name I get when I do GM on the command Get-vmhostnetworkadapter  <servername> -vmkernel | select name,ip,subnetmask

TypeName: Selected.VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.Nic.HostVMKernelVirtualNicImpl

So can it be done?

 

My goal is the following..

 

get-vmhost | sort name | get-view |

select name,

@{N="Datacenter";E={Get-Datacenter -VMHost $_.Name}},

@{N="Type";E={$_.hardware.systeminfo.vendor+" "+ $_.Hardware.systeminfo.model}},

@{N="CPU"; E={"PROC:" + $_.Hardware.CpuInfo.NumCPUPackages + "Cores:" +

$_.Hardware.CpuInfoNumCpuCores + "MHZ:" + [math]::round($_.Hardware.CpuInfo.Hz/1000000,0)}},

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

@{N="NIC";E={$_.Host.Networking.Nic.HostVMKernelVirtualNicImpl.Name}},

@{N="IP";E={$_.Host.Networking.Nic.HostVMKernelVirtualNicImpl.IP}},

@{N="Subnetmask";E={$_.Host.Networking.Nic.HostVMKernelVirtualNicImpl.subnetmask}} | Export-Csv c:\pscripts\hostinfo.csv

 

If someone can explain or point me in the direction of how to extract data from multiple cmdlets using a simple method it would be greatly appreciated.. I have just about every book out there so it is in a book please just point me to it and I will read it.

Thanks in advance.


Viewing all articles
Browse latest Browse all 175116

Trending Articles



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