Invalid input error when configuring exclusions for MARS agent backup schedules via PowerShell

Joel Stockley 5 Reputation points
2024-07-17T03:32:28.3+00:00

MARS agent version: 2.0.9266.0
Operating Systems: Server 2022, 2019, Windows 11
Azure Powershell versions 10.4.1.37722 x64 as well as 12.1.0.38758 x64

We need to deploy the MARS agent and configure backup schedules via powershell to many devices. The entire process is working fine except the step to choose which files/folders to include and exclude in the backup job. We followed the guide at https://learn.microsoft.com/en-us/azure/backup/backup-client-automation roughly, modifying for our needs. The relevant section of code for this is below:

#Create backup schedule
$newpolicy = New-OBPolicy
$sched = New-OBSchedule -DaysofWeek Monday, Wednesday, Friday -TimesofDay 11:00
Set-OBSchedule -Policy $newpolicy -Schedule $sched

#Set retention length in days
$retentionpolicy = New-OBRetentionPolicy -RetentionDays 30
Set-OBRetentionPolicy -Policy $newpolicy -RetentionPolicy $retentionpolicy

#Choose which folders to include in backup
$inclusions = New-OBFileSpec -FileSpec @("C:\Users\")
Add-OBFileSpec -Policy $newpolicy -FileSpec $inclusions

#Choose which file types to exclude from backup
$exclusions = New-OBFileSpec -FileSpec @("C:\*.iso", "C:\*.pst", "C:\*.ost") -Exclude
Add-OBFileSpec -Policy $newpolicy -FileSpec $exclusions

Get-OBPolicy | Remove-OBPolicy -Confirm:$false
Set-OBPolicy -Policy $newpolicy -Confirm:$false

The error given when deploying is:

Add-OBFileSpec : The current operation failed due to an internal service error "Invalid input error". Please retry the operation after some time. If the issue persists, please contact Microsoft support.

Add-OBFileSpec -Policy $newpolicy -FileSpec $exclusions

  • CategoryInfo : NotSpecified: (:) [Add-OBFileSpec], DlsException
  • FullyQualifiedErrorId : CloudInvalidInputError,Microsoft.Internal.CloudBackup.Commands.AddCBFileSpecCommand
$exclusions = New-OBFileSpec -FileSpec @("C:\Users\*.iso", "C:\Users\*.pst", "C:\Users\*.ost") -Exclude

This produced the same error. If I deploy including this line to a device, the deploy job fails with the above error, yet the policy itself gets created successfully on the target endpoint, minus the exclusion list. If I go in to azure backup GUI and manually add the exclusions to the scheduled backup it succeeds as well and the jobs can successfully run.

I have attempted to use the exact same command from the example site:

$Exclusions = New-OBFileSpec -FileSpec @("C:\windows", "C:\temp") -Exclude

and then

Add-OBFileSpec -Policy $newpolicy -FileSpec $Exclusions

and I check the variable value looks correct (same as with my own desired values above):
PS C:\Windows\system32> $Exclusions
FileName :
FilePath :
FileSpec : C:\windows
IsExclude : True
IsRecursive : True

FileName :
FilePath :
FileSpec : C:\temp
IsExclude : True
IsRecursive : True

Then I run the add command again:
Add-OBFileSpec -Policy $NewPolicy -FileSpec $Exclusions
Add-OBFileSpec : The current operation failed due to an internal service error "Invalid input error". Please retry the operation after some time. If the issue persists, please contact Microsoft support.
At line:1 char:1
Add-OBFileSpec -Policy $NewPolicy -FileSpec $Exclusions

  • CategoryInfo : NotSpecified: (:) [Add-OBFileSpec], DlsException
  • FullyQualifiedErrorId : CloudInvalidInputError,Microsoft.Internal.CloudBackup.Commands.AddCBFileSpecCommand
Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,188 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,318 questions
{count} votes