Hi @SriRaghavendran Prabhakaran ,
please give this a try:
$date = (Get-Date).AddDays(-1)
$allObjs = Get-AzStorageFile -Context $ctx -ShareName $sharename
foreach ($obj in $allObjs) {
if ($($obj.ListFileProperties.IsDirectory) -eq $false) {
Write-Host "$($obj.Name) last modified on $($obj.LastModified.DateTime)"
if ($($obj.LastModified.DateTime) -lt $date) {
Write-Host "$($obj.Name) is older than $date and will be deleted" -ForegroundColor Magenta
}
else {
Write-Host "$($obj.Name) is newer than $date and will not be deleted" -ForegroundColor Blue
}
}
}
You should get an output like this:
My script sample will not delete anything. You have to add this by yourself in the if
block.
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten