Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

Try like this

$dsNames = Get-Content .\luns.txt

Get-Datastore -Name $dsNames | %{

    $obj = [ordered]@{

        Datastore = $_.Name

        VM = ''

    }

    $i = 1

    (Get-View -Id $_.ExtensionData.VM -property Name).Name | %{

        If($i -gt 1){

            $obj.Datastore = ''

        }

        $obj.VM = $_

        $i++

        New-Object PSObject -Property $obj

    }

} | Export-Csv D:\Temp\report.csv -NoTypeInformation -UseCulture


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