How can I export List of all VMs ( VMs network VLANs id ) in Cluster from Vcenter ? I don't see there any network details option.
Using Vcenter 6.5
I tried this option. I only replaced Get-VirtualPortGroup
to Get-VDPortgroup
, but not works for me, got some erros
$Portgroups = Get-VDPortgroup |Sort-Object -Unique
$Datastores = Get-Datastore |Sort-Object -Unique
$VMs = get-vm
[System.Collections.ArrayList]$Output = @()
foreach ($currentVM in $VMs) {
$VM = New-Object -TypeName PsObject
$VM | Add-Member -Membertype NoteProperty -Name "Name" -Value $currentVM.Name
foreach ($Portgroup in $Portgroups) {
$VM | Add-Member -MemberType NoteProperty -Name $Portgroup.Name -Value (($currentVM|Get-VDPortgroup).name -contains $Portgroup.Name)
}
foreach ($Datastore in $Datastores) {
$VM | Add-Member -MemberType NoteProperty -Name $Datastore.Name -Value (($currentVM|Get-Datastore).name -contains $Datastore.Name)
}
$Output += $VM
}
$Output |Export-Csv -Path "vm_export.csv"
error:
Get-VDPortgroup : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:9 char:93
+ ... rty -Name $Portgroup.Name -Value (($currentVM|Get-VDPortgroup).name - ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (test-vm:PSObject) [Get-VDPortgroup], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.Vds.Commands.Cmdlets.GetVDPortgroup