Behaviour of Get-AzureStorageFile has changed from 0.9.8 -> 1.0.1
Im seeing a lot of differences in the behaviour of Get-AzureStorageFile in the new version when accessing sub directories of shares - its resulting in a lot of broken scripts
To repro try the following
$storageAccountName = "hamadatest"
$account = Get-AzureStorageAccount -StorageAccountName $storageAccountName -ErrorAction SilentlyContinue
if($account -eq $null)
{
New-AzureStorageAccount -StorageAccountName $storageAccountName -Location 'North Europe'
}
# Create share
$storageKeys = Get-AzureStorageKey -StorageAccountName $storageAccountName
$storagePrimaryKey = $storageKeys.Primary
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storagePrimaryKey
$azureShare = New-AzureStorageShare 'share1' -Context $storageContext
# Create directories
New-AzureStorageDirectory -Share $azureShare -Path 'folder1'
New-AzureStorageDirectory -Share $azureShare -Path 'folder1\folder2'
$azureShare = Get-AzureStorageShare 'share1' -Context $storageContext
# In 0.9.8 the following command returns folder1 - in 1.0.1 it returns folder1
Get-AzureStorageFile -Share $azureShare -Path '' | where Name -EQ 'folder1'
# In 0.9.8 the following command returns **folder2** - in 1.0.1 it returns **folder1**
Get-AzureStorageFile -Share $azureShare -Path 'folder1'
Unable to list folder contents. any workaround?
Check the bug #1543 there is a workaround
@shiningdragon The cmdlet Get-AzureStorageFile should not only be able to list files/directories under a share/directory, but also be able to get instance and attributes of a single file or a directory. The old behavior only can do list, but is pain to get a single file's instance.
With current Get-AzureStorageFile, it can get a single instance of file/directory with Path parameter and list the share/directory if Path is not specified. To list a specific directory, you can first get the directory instance and then list it: $dir = Get-AzureStorageFile -ShareName 'sharename' -Path 'dirpath' -Context $ctx Get-AzureStorageFile -Directory $dir
Feel free to reactivate the issue if the above suggestion does not address your questions.