有没有办法使用PowerShell列出恢复库中列出的所有VMS?
我一直在网上search,只看到命令来pipe理虚拟机,但没有列出它们。 我试图列出所有受保护的VMS和上次备份date。 如果它是可能的。
提前致谢 :)
我试图列出所有受保护的VMS和上次备份date
我们可以使用PowerShell列出恢复服务库中的虚拟机和最新的恢复点 ,如下所示:
Get-AzureRmRecoveryServicesVault -Name "jasonbackup" -ResourceGroupName "backup" | Set-AzureRmRecoveryServicesVaultContext $nameContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType "AzureVM" -Status "Registered" -FriendlyName "jasonvm" Get-AzureRmRecoveryServicesBackupItem -Container $nameContainer -WorkloadType "AzureVM" | select ContainerName,LatestRecoveryPoint
我的虚拟机名称是jasonvm
和jasonvm2
。
=============================================
更新 :
如果我们有很多虚拟机,我们可以使用Foreach
列出Azure虚拟机Name
和LatestRecoveryPoint
,我们可以使用这个脚本:
Get-AzureRmRecoveryServicesVault -Name "jasonbackup" -ResourceGroupName "backup" | Set-AzureRmRecoveryServicesVaultContext $fnames = Get-AzureRmRecoveryServicesBackupContainer -ContainerType "AzureVM" -Status "Registered" | select -ExpandProperty friendlyname foreach ($name in $fnames) { $nameContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType "AzureVM" -Status "Registered" -FriendlyName $name Get-AzureRmRecoveryServicesBackupItem -Container $nameContainer -WorkloadType "AzureVM" | select ContainerName,LatestRecoveryPoint }