Add automatic connection handling and Test-ProxmoxConnection cmdlet

This commit is contained in:
Alphaeus Mote
2025-05-09 14:35:20 -04:00
parent d0433ae21f
commit 7478796d16
7 changed files with 55 additions and 43 deletions
+10 -6
View File
@@ -6,16 +6,19 @@ Import-Module PSProxmox
# Connect to the Proxmox VE server
$credential = Get-Credential -Message "Enter your Proxmox VE credentials"
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam"
Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam"
# Method 1: Create a basic VM
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Start
# Test the connection
Test-ProxmoxConnection
# Method 1: Create a basic VM (uses the default connection automatically)
$vm = New-ProxmoxVM -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Start
# Display the VM information
$vm
# Method 2: Create a VM with more options
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "web-server" `
$vm = New-ProxmoxVM -Node "pve1" -Name "web-server" `
-Memory 4096 -Cores 2 -Sockets 1 -DiskSize 50 -Storage "local-lvm" `
-OSType "l26" -NetworkModel "virtio" -NetworkBridge "vmbr0" `
-Description "Web server for testing" -Start
@@ -24,11 +27,12 @@ $vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "web-server" `
$vm
# Method 3: Create a VM with a specific ID
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "db-server" -VMID 200 `
$vm = New-ProxmoxVM -Node "pve1" -Name "db-server" -VMID 200 `
-Memory 8192 -Cores 4 -DiskSize 100 -Storage "local-lvm" -Start
# Display the VM information
$vm
# Disconnect from the server when done
# Get the current connection and disconnect from the server when done
$connection = Test-ProxmoxConnection -Detailed
Disconnect-ProxmoxServer -Connection $connection