Azure Powershell:删除多个容器中的文件
我一直在为每个容器运行此脚本,以删除超过35天的SQL备份。有人能帮我写一个循环(foreach)来遍历每个容器删除35天以前的文件吗 这是一个容器的脚本,但我需要为每个容器运行它Azure Powershell:删除多个容器中的文件,powershell,azure,Powershell,Azure,我一直在为每个容器运行此脚本,以删除超过35天的SQL备份。有人能帮我写一个循环(foreach)来遍历每个容器删除35天以前的文件吗 这是一个容器的脚本,但我需要为每个容器运行它 $SubScriptionName = "subname" $StorageAccountName = "storagename" Select-AzureSubscription –SubscriptionName $SubScriptionName Set-AzureSubscription –Subscript
$SubScriptionName = "subname"
$StorageAccountName = "storagename"
Select-AzureSubscription –SubscriptionName $SubScriptionName
Set-AzureSubscription –SubscriptionName $SubScriptionName –CurrentStorageAccount $StorageAccountName
$Container = "nameOfContainer"
$CleanupOlderThan35Days = [DateTime]::UtcNow.AddDays(-35)
Get-AzureStorageBlob -Container $Container | Where-Object { $_.LastModified.UtcDateTime -lt $CleanupOlderThan35Days } |Remove-AzureStorageBlob
脚本中心中提供了一个Azure Runbook,可以为您执行此操作 您可以从Azure Automation帐户将其作为Runbook运行(我的首选项),也可以提取完成本地脚本实现所需的PowerShell