function CountFiles
{
Param(
[string]$rootFolder
)
$items
=
Get
-
AzureRmDataLakeStoreChildItem
Account $dataLakeStoreName
Path $rootFolder
$count
0
Write
Host
"Number of files in $rootFolder :"
foreach ($item
in
$items)
if
($item.Type
eq
"FILE"
+
1
}
return
Login
AzureRmAccount
$dataLakeStoreName
"myDataLakeStore" #Replace value with your own Data Lake Store name
#Replace value with your own Data Lake Store name
$folder
"/user" #Replace value with the folder you want to delete files from
CountFiles $folder
"myDataLakeStore"
$rootFolder
"/user/myfolder"
#Replace value with the folder you want to delete files from
Path $rootFolder | Where
Object {$_.Name.Contains(
".TMP"
)}
#Replace value with the extension you want to delete
$fileName
$item.Name
"Deleting $fileName"
Remove
AzureRmDataLakeStoreItem
/
Force
"`n$count file(s) were deleted"
#Replace value with the folder you want to download
$downloadDest
"c:\temp\"
#Replace value with the download destination folder
Export
Destination $downloadDest
Recurse
function GetFolderContent
"`nContents in $rootFolder"
"DIRECTORY"
$nextFolder
($rootFolder
"\"
GetFolderContent $nextFolder
else
GetFolderContent $rootFolder
Host $item.Name
$null
Login-AzureRmAccount
"dataplatformdlsprod"
"/raw/plant/osebergd/ims/history/Compressor"
#Replace value with the folder you want to get contents of
"/user/from"
#Replace value with the folder you want to move files from
$destFolder
"/user/to"
#Replace value with the folder you want to move files to
"Moving $fileName to"
Move
Destination $destFolder
"`n$count file(s) were moved"
function RemoveFileExpiry
[string]$fileName
"Removing expiry on $fileName"
Set
AzureRmDataLakeStoreItemExpiry
Path $fileName
"/user/myfile.jpg"
#Replace value with the file you want to remove expiry on
RemoveFileExpiry $fileName
function RemoveFolderExpiry
[string]$folderName
$now
Date
Path $folderName
($folderName
RemoveFolderExpiry $nextFolder
RemoveFolderExpiry $folderName
"Removing expiry on $folderName/$fileName"
$
global
:count
$folderName
#Replace value with the folder you want to remove expiry on
"`nRemoved expiry on $count file(s)"
function SearchForFile
SearchForFile $nextFolder
SearchForFile $rootFolder
($item.Name
like $searchString)
"found in"
$searchString
"*filename*"
#Replace value with the file you want to search for. Asterisk allowed
function SetFileExpiry
"Setting retention on $fileName"
Expiration $now.AddMonths(
3
#Replace expiry as required
#Replace value with the file you want expiry on
SetFileExpiry $fileName
function SetFolderExpiry
SetFolderExpiry $nextFolder
SetFolderExpiry $folderName
"Setting expiry on $folderName/$fileName"
#Replace value with the folder you want expiry on
"`nSet expiry on $count file(s)"
$sourceFolder
"C:\temp"
#Replace value with the folder you want to upload
$uploadDest
#Replace value with the upload destination path
Import
Path $sourceFolder
Destination $uploadDest
Back to Top