Automation

 View Only
  • 1.  List vms in each folder

    Posted Oct 01, 2008 06:14 PM

    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.



  • 2.  RE: List vms in each folder

    Posted Oct 01, 2008 11:23 PM

    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.



  • 3.  RE: List vms in each folder

    Posted Oct 02, 2008 03:14 AM

    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



  • 4.  RE: List vms in each folder

    Posted Oct 02, 2008 11:53 AM

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

    Thanks Again!!