此脚本可帮助你在本地 Windows 服务器上安装最新的 MARS 代理。 还可以 使用安装程序安装 MARS 代理。
示例脚本
<#
.SYNOPSIS
Sets MARS agent
.DESCRIPTION
Sets MARS agent
.ROLE
Administrators
#>
Set-StrictMode -Version 5.0
$ErrorActionPreference = "Stop"
Try {
    $agentPath = $env:TEMP + '\MARSAgentInstaller.exe'
    Invoke-WebRequest -Uri 'https://aka.ms/azurebackup_agent' -OutFile $agentPath
    & $agentPath /q | out-null
    $env:PSModulePath = (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PSModulePath).PSModulePath
    $azureBackupModuleName = 'MSOnlineBackup'
    $azureBackupModule = Get-Module -ListAvailable -Name $azureBackupModuleName
    if ($azureBackupModule) {
        $true
    }
    else {
        $false
    }
}
Catch {
    if ($error[0].ErrorDetails) {
        throw $error[0].ErrorDetails
    }
    throw $error[0]
}
后续步骤
详细了解 如何使用 PowerShell 通过 MARS 代理部署和管理本地备份。