I need to get a list of VM Folders, Datastores and Networks from a VirtualCenter. I am using Powershell.
I can get the list of folders using Get-Folder and I use the following to get the list of datastores
$dc = Get-Datacenter | get-view
foreach($dstore in $dc.Datastore){
$dstr = Get-VIObjectByVIView $dstore
Write-Host $dstr
}
If I use the same logic and try converting the MOR of $dc.Networks to a variable I keep getting blank results. I get as many blanks as there are networks in the Datacenter.
Any ideas?
Thanks
Have you looked at VESI (thevesi.org) yet? This is a modification of PowerGui written to better manage virtual environments. It will easily produce this info as output and the underlying Powershell code.
-MattG
Thanks for the reply MattG
I haven't tried this as the problem lies with the powershell code itself, not the editor. I am producing a tool for a production environment. The tool has to be based on an Excel spreadsheet and therefore the majority of the code is written using VBA which in turn produces powershell scripts on the fly and runs them. The results of the powershell are re-imported back in to the Excel spreadsheet.
As I stated this is for a production environment and therefore I can only use native Powershell and I am unable to use third party tools.
Regards
So you cant use the VI-Toolkit's Powershell?
-MattG
I had a similar need, and while it's almost a full 2yrs after the original post, I wrote up a script that returns a list of networks on a specific VMHost.
The script is available at my site, https://github.com/jeffpatton1971/mod-posh/blob/master/powershell/production/includes/VMwareManageme... the function is Get-VMHostNetworks.
I believe this particular function does exactly what the original poster requested using powershell cmdlets from vmware.
Message was edited by: Jeff Patton Updated the URL for where my stuff is located.