-
-
Save mritsurgeon/0fd07ec71048097b613e892d063b8acb to your computer and use it in GitHub Desktop.
Add Multiple Veeam backup servers to Veeam Enterprise Manager Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$list = Import-Csv -Path C:\list.csv | |
$servers = $list.name | |
$IPS = $list.Ip | |
$user = 'administrator' | |
$pass = 'password' | |
$pair = "$($user):$($pass)" | |
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) | |
$basicAuthValue = "Basic $encodedCreds" | |
$Headers = @{ | |
Authorization = $basicAuthValue | |
} | |
add-type @" | |
using System.Net; | |
using System.Security.Cryptography.X509Certificates; | |
public class TrustAllCertsPolicy : ICertificatePolicy { | |
public bool CheckValidationResult( | |
ServicePoint srvPoint, X509Certificate certificate, | |
WebRequest request, int certificateProblem) { | |
return true; | |
} | |
} | |
"@ | |
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy | |
$logon = Invoke-webrequest -Method "POST" -Uri https://localhost:9398/api/sessionMngr/?v=latest -Headers $Headers | |
$Response = $logon.Headers | |
$Sessionkey = $Response.'X-RestSvcSessionId' | |
$Headers2 = @{ | |
'X-RestSvcSessionId' = $Sessionkey ; | |
} | |
foreach ($IP in $IPS) | |
{ | |
$body = @{ | |
"Description" = "API added backup Server" ; | |
"DnsNameOrIpAddress" = $IP ; | |
"Port" = "9392" ; | |
"Username" = ".\Administrator" ; | |
"Password" = "password" | |
} | |
Invoke-WebRequest -Method 'POST' -Uri https://localhost:9398/api/backupServers?action=create -Headers $Headers2 -Body ($body|ConvertTo-Json) -ContentType "application/json" | |
} | |
#Get Backup Servers | |
#Invoke-WebRequest -Method 'GET' -Uri https://localhost:9398/api/backupServers -Headers $Headers2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment