为所有ARM存储中的VHD文件创建快照

来源:互联网 发布:intent 获取数据 编辑:程序博客网 时间:2024/04/30 02:36

为所有ARM存储中的VHD文件创建快照

由于现阶段Azure新Portal中虚拟机备份功能还未上线,所以此脚本也可以作为临时的备份选项。
脚本运行截图:


PowerShell脚本内容如下:

#------------------------------------------------------------------------------    # User own the risk, otherwise exit.# # Azure PowerShell Version:  3.6.0## Create by Zeno. #------------------------------------------------------------------------------  #登录订阅Login-AzureRmAccount -EnvironmentName AzureChinaCloud -Credential $(Get-Credential -UserName admin@xxx.partner.onmschina.cn -Message Login_AzureChinaCloud) |Out-Null$storages = Get-AzureRmStorageAccountforeach ($storage in $storages){  # get storage containers  $containers = Get-AzureStorageContainer -Context $storage.Context   foreach ($container in $containers)   {     #get blobs under all containers     $blobs = Get-AzureStorageBlob -Context $storage.Context -Container $container.Name | Where-Object {$_.Name.EndsWith("vhd")}    foreach ($blob in $blobs)    {     if(!$blob.ICloudBlob.IsSnapshot){$blob.ICloudBlob.CreateSnapshot()}    }  }}


阅读全文
0 0
原创粉丝点击