vmware / powerclicore

PowerCLI Core Dockerfile
Apache License 2.0
97 stars 48 forks source link

VimDatastore provider isn't returning path and name correctly #10

Closed quonic closed 6 years ago

quonic commented 7 years ago

When traversing a datastore in powershell, the default behavior of other providers doesn't seem to match the VimDatastore provider.

What I suspect is that .ToString() isn't returning a full path. A kin to [string](Get-Item C:\temp\file.txt) should return C:\temp\file.txt but if you do something like [string](Get-Item vmstores:\vCenter@443\) you get vCenter as well as [string](Get-Item vmstores:\ returns vmstores.

Example code:

function Get-NextItem ($Path) {
    $CurrentItem = Get-Item -Path "$Path\$($_.Name)"
    $ChildItems = Get-ChildItem -Path $Path | Where-Object {$_.PSIsContainer -eq $true}
    If ($CurrentItem.PSIsContainer -eq $true) {
        $ChildItems | ForEach-Object {
            #Get-NextLevel $_ # This is how it should work...
            Get-NextItem "$Path\$($_.Name)" # Ugly hack to it to work...
        }
    }
}
$drive = Get-PSDrive -PSProvider VimDatastore -Name vmstores
$vmstore = "$($drive):\"
Get-NextItem $vmstore
jakerobinson commented 6 years ago

If this issue is still occuring, please open a ticket with VMware GSS for the PowerCLI development team!