Hello,
I have unregistered VMs in many datastores, I need to list them please.
You could do something like this
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
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
You could do something like this
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
Thank you,