VMware Cloud Community
fborges555
Enthusiast
Enthusiast
Jump to solution

Datastore and Vlan Information

Hi gurus

Trying to run a PS that will give me datastore name and Vlan used by all VM in a cluster.

I got this far and sort of work but not entirely

Get-VM | Select Name,

@{N = "Datastore"; E = {[string]::Join(',', (Get-Datastore -Id $_.DatastoreIdList ))}},

@{N="Vlan" , E={[string]::join (',',(Get-VMNetworkAdapterVlan))}}

its all screwy, any help appreciated

Thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The Get-VMNetworkAdapterVlan cmdlet is a Hyper-V cmdlet I'm afraid.

With PowerCLI you could do something like this

Get-VM |

Select Name,

@{N='Datastore';E={(Get-Datastore -Id $_.DatastoreIdList).Name -join '|'}},

@{N='VLAN';E={(Get-VirtualPortgroup -Name (Get-NetWorkAdapter -VM $_).NetworkName).VlanId -join '|'}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

The Get-VMNetworkAdapterVlan cmdlet is a Hyper-V cmdlet I'm afraid.

With PowerCLI you could do something like this

Get-VM |

Select Name,

@{N='Datastore';E={(Get-Datastore -Id $_.DatastoreIdList).Name -join '|'}},

@{N='VLAN';E={(Get-VirtualPortgroup -Name (Get-NetWorkAdapter -VM $_).NetworkName).VlanId -join '|'}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

as always you are crazy goooooddddd

0 Kudos