54 lines
1.5 KiB
PowerShell
54 lines
1.5 KiB
PowerShell
param(
|
|
[Parameter(Mandatory)]
|
|
[ValidateSet("VMware", "HyperV", "Proxmox")]
|
|
[string]$Platform,
|
|
|
|
[Parameter(Mandatory)]
|
|
[string]$Server,
|
|
|
|
[PSCredential]$Credential,
|
|
|
|
[switch]$DryRun
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
$Root = $PSScriptRoot
|
|
|
|
$RequiredModules = @(
|
|
"Modules\Veeam\BackupJobs.psm1",
|
|
"Modules\Platforms\$Platform.psm1"
|
|
)
|
|
|
|
foreach($Module in $RequiredModules) {
|
|
Import-Module (Join-Path $Root $Module) -Force -ErrorAction Stop
|
|
}
|
|
|
|
$Configuration = Get-Content (Join-Path $Root "Config\VeeamConfig.json") -Raw | ConvertFrom-Json
|
|
|
|
if($Platform -eq "Proxmox" -and $null -eq $Credential) {
|
|
$Credential = Get-Credential -Message "Proxmox API-Token-ID und Token-Secret eingeben"
|
|
}
|
|
|
|
switch($Platform) {
|
|
"VMware" { $VirtualMachines = @(Get-VMwareInventory -Server $Server) }
|
|
"HyperV" { $VirtualMachines = @(Get-HyperVInventory -Server $Server) }
|
|
"Proxmox" { $VirtualMachines = @(Get-ProxmoxInventory -Server $Server -ApiCredential $Credential) }
|
|
}
|
|
|
|
$Schedules = New-AlphabeticalBackupSchedules `
|
|
-JobName $Configuration.BackupJob.Name `
|
|
-VirtualMachines $VirtualMachines `
|
|
-ScheduleGroups @($Configuration.BackupJob.ScheduleGroups)
|
|
|
|
[PSCustomObject]@{
|
|
Platform = $Platform
|
|
Server = $Server
|
|
DryRun = $DryRun.IsPresent
|
|
VirtualMachineCount = $VirtualMachines.Count
|
|
VirtualMachines = $VirtualMachines
|
|
Schedules = $Schedules
|
|
JobsCreated = $false
|
|
Message = "Inventar gelesen und Zeitplanentwurf erstellt. Es wurden keine Veeam-Jobs angelegt."
|
|
}
|