VMware Cloud Community
bkolaske
Contributor
Contributor

List vms in each folder

We have folders created for each of our clients. Under each of those parent folders we have a Monthly and Daily folder to split out when they need to get backed up. I have searched, with little luck, on how to document which vm is in which folder. For example if there was a folder called clientx I would like to find a way to document vm x, y, and z are in clientx/monthly and vm a, b,and c are in clientx/daily.

Any help would be appreciated.

Tags (2)
Reply
0 Kudos
3 Replies
admin
Immortal
Immortal

I think Get-Folder Monthly | Get-VM and Get-Folder Daily | Get-VM will work.

If not, Get-Folder HigherLevelFolder | Get-Folder Monthly | Get-VM should do the trick.

munizaba
Contributor
Contributor

Script below (by LucD) will list all vm in each folder if you want to report for individual folders use "findstr" on the end of script:

$report = @()

Get-Folder | foreach-object {

$folder = $_.Name

$_ | Get-VM | foreach-object {

$row = "" | select FolderName, VMName

$row.FolderName = $folder

$row.VMName = $_.Name

$report += $row

}

}

$report | findstr foldername

bkolaske
Contributor
Contributor

Thank you both for your quick response. I can get the information from both of the ideas you posted.

Thanks Again!!

Reply
0 Kudos