Last active
April 14, 2020 18:24
-
-
Save bjh1977/2e98e0a93ccfcc64fcd85a0734ba8af5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# More info here: https://docs.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-directory-file-acl-powershell | |
# | |
Login-AzAccount | |
$ResourceGroupName = '<RESOURCE GROUP NAME>' | |
$StorageAccountName = '<STORAGE ACCOUNT NAME>' | |
$filesystemName = 'cont1' | |
$dirpath = "folderx/y/z1/" | |
# Important! You need the right version of Az.Storage as these cmdlets are not GA.. | |
if (Get-Module -Name Az.Storage -ListAvailable | Where-Object {$_.Version -eq '1.9.1'}) { | |
Write-Host "Az.Storage version 1.9.1 found." -ForegroundColor Cyan | |
} | |
else { | |
Write-Host "Az.Storage version 1.9.1 not found. Installing.." -ForegroundColor Cyan | |
install-Module Az.Storage -Repository PSGallery -RequiredVersion 1.9.1-preview –AllowPrerelease –AllowClobber –Force -Verbose -SkipPublisherCheck | |
} | |
Get-Module AZ.Storage | Remove-Module; Import-Module Az.Storage -RequiredVersion 1.9.1 -Scope Local | |
$storageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -AccountName $StorageAccountName; $ctx = $storageAccount.Context | |
# upload some sample files.. | |
for ($i = 1; $i -le 10; $i++) { | |
$filepath = "c:\temp\file$i.txt" | |
set-content -Path $filepath -Value "The value is $i" | |
$destPath = $dirpath + (Get-Item $filepath).Name | |
New-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $destPath -Source $filepath -Force | |
Remove-Item -Path $filepath | |
} | |
#Get a directory | |
$dirObj = Get-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirpath -ErrorAction SilentlyContinue | |
$dirObj.ACL | |
# Get a file | |
$file = Get-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path "$($dirpath)file1.txt" | |
$file.ACL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment