mirror of
https://github.com/Grace-Solutions/PSProxmox.git
synced 2026-08-12 16:16:56 +00:00
Add automatic connection handling and Test-ProxmoxConnection cmdlet
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user