azure backup
4 TopicsPowerShell command trying to grab files from External Blob Storage
Hi there, We have a ERP company that backsup a Database, and I want to setup a script to automatically grab those backup files from their Azure storage. I wrote a script to communicate with the storage with the secret key, and grab the .backpac files and store them locally on our SQL desktop. Once I am successful there, I am going to setup a Task Scheduler to do this automatically. But, when I try to run the script, I get an argument error. It's probably something simple, but thought I'd ask. Secret Key, Account name and and database replaced with "xxxxxxx" $firstBlob = az storage blob list --account-key xxxxxxxxxx== --account-name xxxxxxx -c xxxxxx | ConvertFrom-Json | Select-Object name, @{Name="lastModified"; Expression={$_.properties.lastModified}}, properties | Sort-Object -Property lastModified -Descending | Select-Object -First 1 # Check if $firstBlob is not null (i.e., there are blobs found) if ($firstBlob) { Write-Host $firstBlob.name "Found! Downloading..." az storage blob download --account-key xxxxx== --account-name xxxxx-c xxxxxx--name $firstBlob.name --file ./backup.bacpac } else { Write-Host "No backups found." } az : ERROR: argument --name/-n: expected one argument At C:\Users\Administrator\Desktop\Azure.ps1:10 char:5 + az storage blob download --account-key xxxxxxxxx... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (ERROR: argument...ed one argument:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError Examples from AI knowledge base: az storage blob download --account-key 00000000 --account-name myaccount --container-name mycontainer --file file.txt --name myblob Downloads a blob to a file path, with automatic chunking and progress notifications. (autogenerated) az storage blob download --account-name myaccount --container-name mycontainer --file file.txt --name myblob Downloads a blob to a file path, with automatic chunking and progress notifications. (autogenerated) https://docs.microsoft.com/en-US/cli/azure/storage/blob#az_storage_blob_download Read more about the command in reference docs514Views0likes1CommentAssistance with looping through multiple subscriptions
Hi Community, I'm using the below script fromhttp://vcloud-lab.com/entries/microsoft-azure/get-azure-virtual-machine-backup-reports-using-powershellto pull Azure VM backup details. Currently I have to run the script against each subscription, I would love to have it loop though all subscriptions. I've been trying to get it working using this examplehttps://www.jpaul.me/2019/05/azure-automation-how-to-quickly-work-with-many-subscriptions/but I'm new to Powershell and am struggling. Any suggestions would be really appreciated. [CmdletBinding(SupportsShouldProcess=$True, ConfirmImpact='Medium', HelpURI='http://vcloud-lab.com', DefaultParameterSetName = 'AllVirtualMachines' )] <# .SYNOPSIS Collect Azure VM Backup Information .DESCRIPTION This Script collects Azure Virtual Machine Backup Recovery service vault information, This report includes the complete backup status Information of VM. .PARAMETER AllVirtualMachines Collect Backup information of the all Azure Virtual Machines, This is default parameter. .PARAMETER VirtualMachineList You can specify for which virtual machine you want backup information. .INPUTS None. Provides virtual machine information. .OUTPUTS Generate Backup information. You can pipe information to Export-CSV. .EXAMPLE PS> .\Get-AzVMBackupInformation.ps1 VM_Name : vcloud-lab-vm01 VM_Location : uksouth VM_ResourceGroupName : VCLOUD-LAB.COM VM_BackedUp : True VM_RecoveryVaultName : vault828 VM_RecoveryVaultPolicy : DailyPolicy-kosrnox0 VM_BackupHealthStatus : Passed VM_BackupProtectionStatus : Healthy VM_LastBackupStatus : Completed VM_LastBackupTime : 27-05-2021 19:32:34 VM_BackupDeleteState : NotDeleted VM_BackupLatestRecoveryPoint : 27-05-2021 19:32:37 VM_Id : /subscriptions/9e22xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/VCLOUD-LAB.COM/providers/Microsoft.Compute/virtualMachines/vcloud-lab-vm01 RecoveryVault_ResourceGroupName : vCloud-lab.com RecoveryVault_Location : uksouth RecoveryVault_SubscriptionId : /subscriptions/9e22xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/vCloud-lab.com/providers/Microsoft.RecoveryServices/vaults/vault828 .EXAMPLE PS> .\Get-AzVMBackupInformation.ps1 -AllVirtualMachines This produces same result as .\Get-AzVMBackupInformation.ps1 from all VMs .EXAMPLE PS> .\Get-AzVMBackupInformation.ps1 -VirtualMachineList Provide either single virtual machine name or in list .LINK Online version: http://vcloud-lab.com .LINK Get-AzVMBackupInformation.ps1 #> Param ( [parameter(Position=0, ParameterSetName = 'AllVMs' )] [Switch]$AllVirtualMachines, [parameter(Position=0, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, ParameterSetName = 'VM' )] [alias('Name')] [String[]]$VirtualMachineList ) #Param Begin { #Collecing Azure virtual machines Information Write-Host "Collecing Azure virtual machine Information" -BackgroundColor DarkGreen if (($PSBoundParameters.ContainsKey('AllVirtualMachines')) -or ($PSBoundParameters.Count -eq 0)) { $vms = Get-AzVM } #if ($PSBoundParameters.ContainsKey('AllVirtualMachines')) elseif ($PSBoundParameters.ContainsKey('VirtualMachineList')) { $vms = @() foreach ($vmname in $VirtualMachineList) { $vms += Get-AzVM -Name $vmname } #foreach ($vmname in $VirtualMachineList) } #elseif ($PSBoundParameters.ContainsKey('VirtualMachineList')) #Collecing All Azure backup recovery vaults Information Write-Host "Collecting all Backup Recovery Vault information" -BackgroundColor DarkGreen $backupVaults = Get-AzRecoveryServicesVault } #Begin Process { $vmBackupReport = [System.Collections.ArrayList]::new() foreach ($vm in $vms) { $recoveryVaultInfo = Get-AzRecoveryServicesBackupStatus -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName -Type 'AzureVM' if ($recoveryVaultInfo.BackedUp -eq $true) { Write-Host "$($vm.Name) - BackedUp : Yes" #Backup Recovery Vault Information $vmBackupVault = $backupVaults | Where-Object {$_.ID -eq $recoveryVaultInfo.VaultId} #Backup recovery Vault policy Information $container = Get-AzRecoveryServicesBackupContainer -ContainerType AzureVM -VaultId $vmBackupVault.ID -FriendlyName $vm.Name #-Status "Registered" $backupItem = Get-AzRecoveryServicesBackupItem -Container $container -WorkloadType AzureVM -VaultId $vmBackupVault.ID } #if ($recoveryVaultInfo.BackedUp -eq $true) else { Write-Host "$($vm.Name) - BackedUp : No" -BackgroundColor DarkRed $vmBackupVault = $null $container = $null $backupItem = $null } #else if ($recoveryVaultInfo.BackedUp -eq $true) [void]$vmBackupReport.Add([PSCustomObject]@{ VM_Name = $vm.Name VM_Location = $vm.Location VM_ResourceGroupName = $vm.ResourceGroupName VM_BackedUp = $recoveryVaultInfo.BackedUp VM_RecoveryVaultName = $vmBackupVault.Name VM_RecoveryVaultPolicy = $backupItem.ProtectionPolicyName VM_BackupHealthStatus = $backupItem.HealthStatus VM_BackupProtectionStatus = $backupItem.ProtectionStatus VM_LastBackupStatus = $backupItem.LastBackupStatus VM_LastBackupTime = $backupItem.LastBackupTime VM_BackupDeleteState = $backupItem.DeleteState VM_BackupLatestRecoveryPoint = $backupItem.LatestRecoveryPoint VM_Id = $vm.Id RecoveryVault_ResourceGroupName = $vmBackupVault.ResourceGroupName RecoveryVault_Location = $vmBackupVault.Location RecoveryVault_SubscriptionId = $vmBackupVault.ID }) #[void]$vmBackupReport.Add([PSCustomObject]@{ } #foreach ($vm in $vms) } #Process end { $vmBackupReport } #end7.9KViews0likes6CommentsInstall-Module MSOnline - not working
Hi all, I am struggling to install:Install-Module MSOnline I get: I have tried: Get-PSRepository WARNING: Unable to find module repositories. When I run:Register-PSRepository -Default I get no error but when trying to runGet-PSRepository again i getWARNING: Unable to find module repositories. Any ideas on how to fix this?Solved20KViews0likes1CommentAzureFiles backup restore
Hello, I created AzureFiles backup and want to restore So I use this script: Select-AzureRmSubscription -SubscriptionId $AzureSubscriptionId $Vault = Get-AzureRmRecoveryServicesVault -Name $BackupVault Set-AzureRmRecoveryServicesVaultContext -Vault $Vault $NamedContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureStorage –Status Registered -FriendlyName $FileShareName $BackupItem = Get-AzureRmRecoveryServicesBackupItem –Container $NamedContainer –WorkloadType AzureFiles $StartDate = (Get-Date).AddDays(-7) $EndDate = Get-Date $RecoveryPoint = Get-AzureRmRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() $RestoreJob = Restore-AzureRmRecoveryServicesBackupItem -RecoveryPoint $RecoveryPoint[0] -StorageAccountName $StorageAccount -StorageAccountResourceGroupName $ResourceGroupName But I get an error: Get-AzureRmRecoveryServicesBackupRecoveryPoint : Cannot convert 'System.Object[]' to the type 'Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.ItemBase' required by parameter 'Item'. Specified method is not supported. At line:46 char:71 + ... -AzureRmRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartD ... + ~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-AzureRmReco...upRecoveryPoint], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmR ecoveryServicesBackupRecoveryPoint How to solve this?1.9KViews0likes2Comments