Files

76 lines
2.6 KiB
PowerShell
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<#
Variablenblock
#>
#
$Global:pvecredential = Get-Credential -UserName "root" -Message "Anmeldung am Proxmox"
$pveUsername = ($Global:pvecredential).UserName
$pvePwENcrypt = ConvertFrom-SecureString -SecureString ($Global:pvecredential).Password
$hostpve = Read-Host 'Bitte die IP des Servers eingeben: '
$ticket = (Connect-PveCluster -HostsAndPorts $($hostpve)':8006' -Credentials $Global:pvecred -SkipCertificateCheck | Where-Object Ticket)
$vers = $PSVersionTable.PSVersion.Major
if ($vers -gt '5') {
Write-Host "
Mit Ihrer Version $vers kann das Script ausgeführt werden.
"
}
else {
Write-Host "Mit Ihrer Powershell Version kann dieses Script nicht ausgeführt werden."
}
function newvm {
param (
[Parameter(Mandatory=$true)]
[ValidateSet("SataN","IdeN","ScsiN")]$hddtype
)
$vmid = Read-Host "Geben Sie die VM ID ein : "
$core = Read-Host "Wieviele Core's soll die VM haben : "
$mem = Read-Host "Wieviel RAM soll die VM haben, einbae in MB: "
$hdd = Read-Host "Wie groß soll die Festplatte sein, eingabe in GB: "
$hddtype = Read-Host "Was für ein HDD Typ soll es sein (SataN, Ide, ScsiN): "
$hddlocation = Read-Host "Wo Soll die HDD liegen: "
$storageConfig = @{ 1 = "$($hddlocation):$($hdd)" }
$storageConfig
New-PveNodesQemu -PveTicket $ticket -Vmid $vmid -Description "Posh Erstellt" -Cores $core -Memory $mem -Agent "True" enable -Node "Proxmox-Hyber-V" -$($hddtype) $storageConfig
Write-Host "Function New VM"11
}
function change {
#New-PveNodesQemu -PveTicket $ticket -Vmid 101 -Description "Posh Erstellt" -Cores 4 -Memory 1024 -Agent enable -Sata0':'23 -Node "Proxmox-Hyber-V"
Write-Host "Function Change VM"
}
function delete {
#New-PveNodesQemu -PveTicket $ticket -Vmid 101 -Description "Posh Erstellt" -Cores 4 -Memory 1024 -Agent enable -Sata0':'23 -Node "Proxmox-Hyber-V"
Write-Host "Function delete VM"
}
function Show-CustomMenu
{
param (
[string]$menuname = 'Proxmox VE VM Menü'
)
Clear-Host
Write-Host "================ $menuname ================"
Write-Host "1: Wähle '1' Erstellung einer Neues VM"
Write-Host "2: Wähle '2' Ändern einer VM"
Write-Host "3: Wähle '3' Löschen einer VM"
Write-Host "x: Beenden "
}
# Menue aufrufen und Titel uebergeben
Show-CustomMenu menuname 'Proxmox VE VM Menü'
do {
$choice = Read-Host Show-CustomMenu
switch ($choice) {
1 { newvm -hddtype SataN }
2 { change }
3 { delete }
x { return }
}
} while (
$choice = "X"
)