Hey all,
I’m working through a customize OVF process on a Windows VM that someone in the community wrote and I'm struggling to find out what is getting stored in these variables. It’s pulling from an OVF Environment xml file that I’ve screenshot below, but any ideas on how to write-host to print what is actually getting stored in each variable so I can see why some aren’t passing properly?
$vmenvxml = 'D:\vmconfig\vmenv\vmenv.xml'
# Import XMLs save those as variables.
[xml]$vmenv = Get-Content $vmenvxml
# Collect Variables from vmenv XML
$vmHostname = $vmenv.Environment.PropertySection.Property | ?{ $_.key -like '1._Hostname' } | select -expand value
$vmIP = $vmenv.Environment.PropertySection.Property | ?{ $_.key -like '2._IP_Address' } | select -expand value
$vmNetmask = $vmenv.Environment.PropertySection.Property | ?{ $_.key -like '3._Subnet_Mask' } | select -expand value
$vmGW = $vmenv.Environment.PropertySection.Property | ?{ $_.key -like '4._Default_Gateway' } | select -expand value
$vmDNS1 = $vmenv.Environment.PropertySection.Property | ?{ $_.key -like '5._Primary_DNS' } | select -expand value
$vmDNS2 = $vmenv.Environment.PropertySection.Property | ?{ $_.key -like '6._Secondary_DNS' } | select -expand value
XML OVF Environment:
<?xml version="1.0" encoding="UTF-8"?>
<Environment
xmlns="http://schemas.dmtf.org/ovf/environment/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
xmlns:ve="http://www.vmware.com/schema/ovfenv"
oe:id=""
ve:vCenterId="vm-230">
<PlatformSection>
<Kind>VMware ESXi</Kind>
<Version>6.7.0</Version>
<Vendor>VMware, Inc.</Vendor>
<Locale>en</Locale>
</PlatformSection>
<PropertySection>
<Property oe:key="1._Hostname" oe:value="demo-custom"/>
<Property oe:key="2._IP_Address" oe:value="1.1.1.2"/>
<Property oe:key="3._Subnet_Mask" oe:value="255.255.255.0"/>
<Property oe:key="4._Default_Gateway" oe:value="1.1.1.1"/>
<Property oe:key="5._Primary_DNS" oe:value="2.2.2.2"/>
<Property oe:key="6._Secondary_DNS" oe:value="3.3.3.3"/>
</PropertySection>
</Environment>