Version 1.0 of Configure
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
function Get-HyperVInventory {
|
||||
param([Parameter(Mandatory)][string]$Server)
|
||||
|
||||
foreach($Name in @("Get-VBRServer", "Find-VBRHvEntity")) {
|
||||
if($null -eq (Get-Command $Name -ErrorAction SilentlyContinue)) {
|
||||
throw "Veeam-Befehl nicht verfügbar: $Name"
|
||||
}
|
||||
}
|
||||
|
||||
$VBRServer = Get-VBRServer -Name $Server |
|
||||
Where-Object { $_.Type -in @("HvServer", "HvCluster", "Scvmm") } |
|
||||
Select-Object -First 1
|
||||
|
||||
if($null -eq $VBRServer) {
|
||||
throw "Hyper-V-Server ist in Veeam nicht registriert: $Server"
|
||||
}
|
||||
|
||||
@(Find-VBRHvEntity -Server $VBRServer -HostsAndVMs |
|
||||
Where-Object { $_.Type -match "Vm" } |
|
||||
Select-Object -ExpandProperty Name -Unique)
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Get-HyperVInventory
|
||||
@@ -0,0 +1,75 @@
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
function Get-ProxmoxInventory {
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$Server,
|
||||
[Parameter(Mandatory)][PSCredential]$ApiCredential,
|
||||
[switch]$TrustSelfSignedCertificate
|
||||
)
|
||||
|
||||
$Secret = $ApiCredential.GetNetworkCredential().Password
|
||||
$Headers = @{ Authorization = "PVEAPIToken=$($ApiCredential.UserName)=$Secret" }
|
||||
$Uri = "https://$Server`:8006/api2/json/cluster/resources?type=vm"
|
||||
$PreviousProtocol = [Net.ServicePointManager]::SecurityProtocol
|
||||
$PreviousCertificatePolicy = $null
|
||||
$CertificatePolicyChanged = $false
|
||||
$RequestParameters = @{
|
||||
Method = "Get"
|
||||
Uri = $Uri
|
||||
Headers = $Headers
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
|
||||
try {
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
if($TrustSelfSignedCertificate) {
|
||||
$InvokeRestMethod = Get-Command Invoke-RestMethod -ErrorAction Stop
|
||||
|
||||
if($InvokeRestMethod.Parameters.ContainsKey("SkipCertificateCheck")) {
|
||||
$RequestParameters["SkipCertificateCheck"] = $true
|
||||
}
|
||||
else {
|
||||
if($null -eq ("TemporaryTrustAllCertificatePolicy" -as [type])) {
|
||||
Add-Type -TypeDefinition @"
|
||||
using System.Net;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
public sealed class TemporaryTrustAllCertificatePolicy : ICertificatePolicy
|
||||
{
|
||||
public bool CheckValidationResult(
|
||||
ServicePoint servicePoint,
|
||||
X509Certificate certificate,
|
||||
WebRequest request,
|
||||
int certificateProblem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
"@
|
||||
}
|
||||
|
||||
$PreviousCertificatePolicy = [Net.ServicePointManager]::CertificatePolicy
|
||||
[Net.ServicePointManager]::CertificatePolicy =
|
||||
New-Object TemporaryTrustAllCertificatePolicy
|
||||
$CertificatePolicyChanged = $true
|
||||
}
|
||||
}
|
||||
|
||||
$Response = Invoke-RestMethod @RequestParameters
|
||||
@($Response.data |
|
||||
Where-Object { $_.type -eq "qemu" } |
|
||||
Select-Object -ExpandProperty name -Unique)
|
||||
}
|
||||
finally {
|
||||
[Net.ServicePointManager]::SecurityProtocol = $PreviousProtocol
|
||||
if($CertificatePolicyChanged) {
|
||||
[Net.ServicePointManager]::CertificatePolicy = $PreviousCertificatePolicy
|
||||
}
|
||||
$Secret = $null
|
||||
$Headers = $null
|
||||
$RequestParameters = $null
|
||||
}
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Get-ProxmoxInventory
|
||||
@@ -0,0 +1,25 @@
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
function Get-VMwareInventory {
|
||||
param([Parameter(Mandatory)][string]$Server)
|
||||
|
||||
foreach($Name in @("Get-VBRServer", "Find-VBRViEntity")) {
|
||||
if($null -eq (Get-Command $Name -ErrorAction SilentlyContinue)) {
|
||||
throw "Veeam-Befehl nicht verfügbar: $Name"
|
||||
}
|
||||
}
|
||||
|
||||
$VBRServer = Get-VBRServer -Name $Server |
|
||||
Where-Object { $_.Type -in @("VC", "ESXi", "ESX") } |
|
||||
Select-Object -First 1
|
||||
|
||||
if($null -eq $VBRServer) {
|
||||
throw "VMware-Server ist in Veeam nicht registriert: $Server"
|
||||
}
|
||||
|
||||
@(Find-VBRViEntity -Server $VBRServer -VMsAndTemplates |
|
||||
Where-Object { $_.Type -match "Vm" } |
|
||||
Select-Object -ExpandProperty Name -Unique)
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Get-VMwareInventory
|
||||
Reference in New Issue
Block a user