VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to get folder name in the script

Hi,

Please help, as I am unable to get the folder name in the script

$metrics = "disk.numberwrite.summation","disk.numberread.summation"
$start = (Get-Date).AddMinutes(-5)
$report = @()
$vms = Get-VM | where {$_.PowerState -eq "PoweredOn"}
$stats = Get-Stat -Realtime -Stat $metrics -Entity $vms -Start $start
$interval = $stats[0].IntervalSecs
$lunTab = @{}
foreach($ds in (Get-Datastore -VM $vms | where {$_.Type -eq "VMFS"})){
$ds.ExtensionData.Info.Vmfs.Extent | %{
$lunTab[$_.DiskName] = $ds.Name
}
}
$report = $stats | Group-Object -Property {$_.Entity.Name},Instance | %{
New-Object PSObject -Property @{

Folder = Get-VM $_ | Select Folder 
VM = $_.Values[0]
Disk = $_.Values[1]
IOPSMax = ($_.Group | `
Group-Object -Property Timestamp | `
%{$_.Group[0].Value + $_.Group[1].Value} | `
Measure-Object -Maximum).Maximum / $interval
Datastore = $lunTab[$_.Values[1]]
}
}
$report

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try with

        Folder        = (Get-VM $_.Values[0]).Folder.Name


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try with

        Folder        = (Get-VM $_.Values[0]).Folder.Name


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

that worked. Thank you very much.

0 Kudos