Hi,
I have a issue exporting the below command output to excel
get-vm | where { $_ | get-cddrive | where { $_.ConnectionState.Connected -eq "true" -and $_.ISOPath -like "*.ISO*"} } | select @{N="Folder";E={$_.Folder.Name}}, Name, @{N="ISO Path";E={(Get-CDDrive $_).isopath }} | Export-Excel -Path reportlocation1.xlsx
When I execute the above command, in the ISO Path is incorrect, the same command works fine in the Powershell prompt
Please help
Try like this
Get-CDDrive |
where { $_.ConnectionState.Connected -eq "true" -and $_.ISOPath -like "*.ISO*"} |
select @{N="VM";E={$_.Parent.Name}},
@{N='ISO Path';E={$_.IsoPath}} |
Export-Excel -Path reportlocation1.xlsx
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Do you have VMs with more than 1 CD drive?
Try like this
select @{N="Folder";E={$_.Folder.Name}}, Name,
@{N="ISO Path";E={(Get-CDDrive -VM $_).isopath -join '|' }} |
Export-Excel -Path reportlocation1.xlsx
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD,
I have few VMs where 2 or more ISO are mounted. with the above script, I am getting as below
Eg:
Name ISO Path
VM1 ISO1| ISO2 | ISO3
I would like to get VM Name and first ISO path in the one line
Eg :
Name ISO Path
VM1 ISO1
VM1 ISO2
VM1 ISO3
Try like this
Get-CDDrive |
where { $_.ConnectionState.Connected -eq "true" -and $_.ISOPath -like "*.ISO*"} |
select @{N="VM";E={$_.Parent.Name}},
@{N='ISO Path';E={$_.IsoPath}} |
Export-Excel -Path reportlocation1.xlsx
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perfect...thank you very much