Hello Techies,
Need your help in extracting the below information in CSV file for the both Windows & Linux VM's.
1> IP Address
2> Subnet Mask
3> Gateway
4> DNS (Primary & Secondary)
5> WINS (Primary & Secondary)
I'm looking for output something like this
| Server Name | Production IP | Production Subnet | Production Gateway | Production DNS1 | Production DNS2 | Production WINS1 | Production WINS2 | Backup IP | Backup Subnet | Backup Gateway | Backup DNS1 | Backup DNS2 | Backup WINS1 | Backup WINS2 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Win2K12 | ||||||||||||||
| RHEL6 | ||||||||||||||
| RHEL7 |
Thanks in advance,
Samojit Das
If these VMs have VMware Tools installed, that information can be retrieved.
But you will have to provide some more information.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello LucD,
Sorry for the confusion.
Yes VM tools are Running and Current.
The OS which are configured are from Win2K to Win2K12 and RHEL 4 to 7.
Yes 2 NIC's mapped to different subnets along with different IP,Subnet,gateway,DNS & WINS servers.
Let me know if you have any other concerns.
Thanks,
Samojit Das
Just one, how do you determine which NIC is Production and which is Backup?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Do you mean at the OS level then its like Front LAN (Prod) & backup lan (backup) in windows.
and if Linux/ Unix then with eth0(Prod) & eth1 (backup).
From vCenter level we can determine using the IP range like for Prod it will be X.X.X.X & backup will be y.y.y.y
Currently this is how am trying to extract the details
Currently this what I'm trying
Import-csv E:\Samojit_Data_backup_27Dec2017\D\Scripts\Server_List.csv |
foreach {
$server = $_.ServerName
foreach ($servers in $server) {
Get-VM -Name $servers | Select Name,
@{N="IP Address";E={[string]::Join(", ", @( $_.guest.IPAddress | where {($_.Split(".")).length -eq 4}))}},
@{Name="Primary DNS";E={$_.ExtensionData.Guest.net.dnsconfig.IpAddress[0]}},
@{Name="Secondary DNS";E={$_.ExtensionData.Guest.net.Exportdnsconfig.IpAddress[1]}},
@{Name="Primary WINS";E={$_.ExtensionData.Guest.net.netbiosconfig.primarywins}},
@{Name="Secondary WINS";E={$_.ExtensionData.Guest.net.netbiosconfig.SecondaryWINS}},
@{N='Gateway';E={[string]::Join(',',($vm.ExtensionData.Guest.IpStack.IpRouteConfig.IpRoute | %{if($_.Gateway.IpAddress){$_.Gateway.IpAddress}}))}} |
Export-CSV -path E:\Samojit_Data_backup_27Dec2017\D\Scripts\VM_List_Target.csv -NoTypeInformation -UseCulture -Append }
And what is the problem with that code?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not getting the desired output.
| Name | IP Address | Primary DNS | Secondary DNS | Primary WINS | Secondary WINS | Gateway | Subnet Mask |
| RHEL7_SAMOJIT | 192.168.10.66 | ||||||
| RHEL6_Samojit | 192.168.10.61 | ||||||
| WIN2K8_Samojit | 192.168.10.247, 192.168.10.242 | 192.168.10.50 | 192.168.10.255 | 192.168.10.254 |
