Hi all,
I am trying to import multiple OVA's in to a VMC on AWS environment. These OVA.s sometimes have multiple vNIC's connected. with the get-ovfconfigueration cmdlet
I can see all the old networkmappings.
PS C:\Windows\system32> $ovfPath = "\my.ova"
PS C:\Windows\system32> $ovfConfig = Get-OvfConfiguration -Ovf $ovfPath
PS C:\Windows\system32> $ovfconfig
====================================
OvfConfiguration: my.ova
Properties:
-----------
NetworkMapping
PS C:\Windows\system32> $ovfconfig.NetworkMapping
Portgroup1 Portgroup2
-------------- ------------
Is there an easy way to change all the networkmappings (I do not know the content of the networkmapping upfront ) to a same (NSX-T) portgroup?
thanks
Looks like I misread the structure of the object.
Try like this
$ovfPath = "\my.ova"
$ovfConfig = Get-OvfConfiguration -Ovf $ovfPath
$ovfconfig.NetworkMapping | Get-Member -MemberType CodeProperty |
ForEach-Object -Process {
$ovfConfig.NetworkMapping."$($_.Name)".Value = $pgName
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Would this work?
It assumes that all networks point to the same portgroup 'xyz'
$ovfPath = "\my.ova"
$ovfConfig = Get-OvfConfiguration -Ovf $ovfPath
$ovfconfig.NetworkMapping |
ForEach-Object -Process {
$netName = ($_ | Get-Member -MemberType CodeProperty).Name
$ovfConfig.NetworkMapping."$netName".Value = $pgName
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
thanks again for the quick response
tried to code but get this error
Get-Member : You must specify an object for the Get-Member cmdlet.
At line:3 char:21
+ $netName = ($_ | Get-Member -MemberType CodeProperty).Name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
+ FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
The property 'Value' cannot be found on this object. Verify that the property exists and can be set.
At line:5 char:4
+ $ovfConfig.NetworkMapping."$netName".Value = $pgName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Hi,
when I put everything on 1 line
$ovfconfig.NetworkMapping |ForEach-Object -Process {$netName = ($_ | Get-Member -MemberType CodeProperty).Name ;$ovfConfig.NetworkMapping."$netName".Value = $pgName}
I get this error
The property 'Value' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:113
+ ... Property).Name ;$ovfConfig.NetworkMapping."$netName".Value = $pgName}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Can you check what this shows?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PS C:\Windows\system32> $ovfconfig.NetworkMapping | Get-Member
TypeName: System.Object
Name MemberType Definition
---- ---------- ----------
Externalvlan CodeProperty VMware.VimAutomation.Sdk.Util10Ps.ObjectCustomization.SimpleExtensionProperty
master0002dvlp CodeProperty VMware.VimAutomation.Sdk.Util10Ps.ObjectCustomization.SimpleExtensionProperty
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
PS C:\Windows\system32> $ovfconfig.NetworkMapping.Portgroup1 | get-member
TypeName: VMware.VimAutomation.ViCore.Impl.V1.Ovf.OvfPropertyImpl
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetPropertyPath Method string GetPropertyPath(), string OvfProperty.GetPropertyPath()
GetType Method type GetType()
ToString Method string ToString()
DefaultValue Property System.Object DefaultValue {get;}
Description Property string Description {get;}
Key Property string Key {get;}
OvfTypeDescription Property string OvfTypeDescription {get;}
Value Property System.Object Value {get;set;}
Looks like I misread the structure of the object.
Try like this
$ovfPath = "\my.ova"
$ovfConfig = Get-OvfConfiguration -Ovf $ovfPath
$ovfconfig.NetworkMapping | Get-Member -MemberType CodeProperty |
ForEach-Object -Process {
$ovfConfig.NetworkMapping."$($_.Name)".Value = $pgName
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
A BIG POWERSHELL GURU like you can also have a moment of weakness . 🙂
THANKS A LOT
looks like a still need to learn a lot 🙂
Gert
Hi,
I also have some VMs that where exported out of a VMC on AWS environment with a NSX-T envirnment.
needed to change some stuff in the command
$ovfconfig.NetworkMapping.nsx |
Get-Member -MemberType CodeProperty |
ForEach-Object -Process { $ovfConfig.NetworkMapping.nsx."$($_.Name)".Value = $pgName }
Greetings
Gert