VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot
Jump to solution

Listing content of datastores

Hello,

I have unregistered VMs in many datastores, I need to list them please.

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-Datastore -Name MyDS |

ForEach-Object -Process {

    New-PSDrive -Name TgtDS -Location $_ -PSProvider VimDatastore -Root '\' | Out-Null

    Get-ChildItem -Path TgtDS: -Recurse | where{$_.PSIsContainer} | Select Datastore,DatastoreFullPath

    Remove-PSDrive -Name TgtDS

} | Export-Csv -Path .\report.csv -UseCulture -NoTypeInformation


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

View solution in original post

Reply
0 Kudos
3 Replies
MRoushdy
Hot Shot
Hot Shot
Jump to solution

I have more than 30 datastore that I must list their content, the following script didn't do it for me, and I need to list the datastore name, as well as the childitem type "datastrefolder" if possible please:

$ds = Get-Datastore -Name MyDS

New-PSDrive -Name TgtDS -Location $ds -PSProvider VimDatastore -Root '\' | Out-Null

Get-ChildItem -Path TgtDS: -Recurse

Remove-PSDrive -Name TgtDS

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-Datastore -Name MyDS |

ForEach-Object -Process {

    New-PSDrive -Name TgtDS -Location $_ -PSProvider VimDatastore -Root '\' | Out-Null

    Get-ChildItem -Path TgtDS: -Recurse | where{$_.PSIsContainer} | Select Datastore,DatastoreFullPath

    Remove-PSDrive -Name TgtDS

} | Export-Csv -Path .\report.csv -UseCulture -NoTypeInformation


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

Reply
0 Kudos
MRoushdy
Hot Shot
Hot Shot
Jump to solution

Thank you,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos