VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

unable to get the CSV output

Hi,

I am unable to get the CSV output for below as I the csv output shows

Length

"24"

"36"

Please help

$dCenter = "MyDC"
$cluster = "Compute"
$clusterInfo = Get-Datacenter -Name $dCenter | get-cluster $cluster
$vmHosts = $clusterInfo | get-vmhost | select -ExpandProperty Name
$RDMNAAs = $clusterInfo | Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select -ExpandProperty ScsiCanonicalName -Unique
$RDMNAAs | Export-CSV -Path ".\RDMs.csv" -NoTypeInformation -UseCultur

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

$RDMNAAs = $clusterInfo | Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select -Property ScsiCanonicalName -Unique
$RDMNAAs | 
ConvertTo-Csv -NoTypeInformation |
Select-Object -Skip 1 |
Set-Content -Path ".\RDMs.csv"


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Did you try with

Select -Property ScsiCanonicalName -Unique

instead of

Select -ExpandProperty ScsiCanonicalName -Unique


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

I tried as below, it worked. but I dont need header. how can I get the output without header in CSV

Select -Property ScsiCanonicalName -Unique

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try something like this

$RDMNAAs = $clusterInfo | Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select -Property ScsiCanonicalName -Unique
$RDMNAAs | 
ConvertTo-Csv -NoTypeInformation |
Select-Object -Skip 1 |
Set-Content -Path ".\RDMs.csv"


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

That worked perfect :)...Thank you very much

0 Kudos