Hi,
I'm trying to search all the folders that exists on different datastores in my organization using PowerCLI.
The thing is that I found some commands to get the VMs folders.
But what about folders that are non VM related or VMs that are not in the inventory?
You can use the VimDatastore provider.
Something like
$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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use the VimDatastore provider.
Something like
$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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Thanks for the fast reply!
It worked for local datastores, tried on a storage datastore and it shown me this error:
You have multiple datastores with the same name?
That means $ds is an array of datastore objects.
Try picking one of the entries for the New-PSDrive cmdlet
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
No, I have the same datastore linked on multiple servers.
Tried with this one "$ds = Get-Datastore -Name VMDATA01 | select -First 1" and worked!
Thanks!