I want to delete all the files under an Azure data lake folder, and I am writing the following Powershell script to do it.
$tenantid = "xxxx-xxxxx-xxxxxxx-xxx"
$serviceprincipalid = "xxxx-xxxxxx-xxxxxxx-xxx"
$serviceprincipalkey = ConvertTo-SecureString "xxxxxxxxxxxxx" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($serviceprincipalid,$serviceprincipalkey)
$adlspath = "/Demo/"
$accountname = "testserv01"
Login-AzureRmAccount -Credential $psCred -TenantId $tenantid -ServicePrincipal
$AllFiles = New-Object Collections.Generic.List[Microsoft.Azure.Commands.DataLakeStore.Models.DataLakeStoreItem];
$AllFiles = Get-AzureRmDataLakeStoreChildItem -AccountName $accountname -Path $adlspath
foreach($DelFiles in $AllFiles)
{
$delfilepath = $adlspath + $DelFiles.Name
Remove-AzureRmDataLakeStoreItem -AccountName $accountname -Paths $delfilepath -Force:$true
}
NOTE: I have masked certain values for security reason.
However, I am getting the following error while doing so:
$AllFiles = New-Object "System.Collections.Generic.List``1[Microsoft.Azure.Commands.DataLakeStore.Models.DataLakeStoreItem]"
New-Object : Cannot find type [System.Collections.Generic.List`1[Microsoft.Azure.Commands.DataLakeStore.Models.DataLakeStoreItem]]: make sure the assembly containing this type is loaded.
