Add comprehensive documentation and examples

This commit is contained in:
Alphaeus Mote
2025-04-28 14:59:49 -04:00
parent 45433064b5
commit c4bea36ece
16 changed files with 2077 additions and 23 deletions
+36 -23
View File
@@ -1,4 +1,4 @@
# PSProxmox
# PSProxmox Documentation
PSProxmox is a C#-based PowerShell module for managing Proxmox VE clusters. It provides a comprehensive set of cmdlets for interacting with Proxmox VE API, featuring structured return objects, mass deployment tools, automatic IP management, and more.
@@ -12,47 +12,60 @@ PSProxmox is a C#-based PowerShell module for managing Proxmox VE clusters. It p
- **Structured Objects**: All outputs are typed C# classes (PowerShell-native)
- **Pipeline Support**: Cmdlets support pipeline input where appropriate
## Getting Started
- [Installation Guide](guides/Installation.md)
- [Connection Guide](guides/Connection.md)
- [Authentication Methods](guides/Authentication.md)
## Documentation
- [Cmdlet Reference](cmdlets/README.md) - Detailed documentation for all cmdlets
- [Examples](examples/README.md) - Example scripts for common tasks
- [Guides](guides/README.md) - Comprehensive guides for various topics
## Requirements
- PowerShell 5.1 or PowerShell 7+
- .NET Framework 4.7.2 or .NET Core 2.0+
## Installation
```powershell
# Install from PSGallery (when published)
Install-Module -Name PSProxmox
# Import the module
Import-Module PSProxmox
```
## Quick Start
```powershell
# Connect to a Proxmox server
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
# Install from PowerShell Gallery
Install-Module -Name PSProxmox -Scope CurrentUser
# Import the module
Import-Module PSProxmox
# Connect to a Proxmox VE server
$credential = Get-Credential
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam"
# Get all VMs
$vms = Get-ProxmoxVM -Connection $connection
# Create a new VM
$newVM = New-ProxmoxVM -Connection $connection -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Start
# Start a VM
Start-ProxmoxVM -Connection $connection -VMID $newVM.VMID
# Disconnect from the server
# Disconnect when done
Disconnect-ProxmoxServer -Connection $connection
```
## Documentation
## Using the Documentation
For detailed documentation on each cmdlet, use the built-in PowerShell help:
For detailed documentation on each cmdlet, you can:
```powershell
Get-Help Connect-ProxmoxServer -Full
```
1. Use the built-in PowerShell help:
```powershell
Get-Help Connect-ProxmoxServer -Full
```
2. Browse the [Cmdlet Reference](cmdlets/README.md) for detailed documentation on all cmdlets.
3. Check the [Examples](examples/README.md) for example scripts for common tasks.
4. Read the [Guides](guides/README.md) for comprehensive guides on various topics.
## Contributing
+286
View File
@@ -0,0 +1,286 @@
# Connect-ProxmoxServer
Connects to a Proxmox VE server.
## Syntax
```powershell
Connect-ProxmoxServer
-Server <String>
-Username <String>
-Password <SecureString>
[-Realm <String>]
[-Port <Int32>]
[-UseSSL <Boolean>]
[-SkipCertificateValidation <Boolean>]
[-Timeout <Int32>]
[<CommonParameters>]
```
```powershell
Connect-ProxmoxServer
-Server <String>
-Credential <PSCredential>
[-Realm <String>]
[-Port <Int32>]
[-UseSSL <Boolean>]
[-SkipCertificateValidation <Boolean>]
[-Timeout <Int32>]
[<CommonParameters>]
```
```powershell
Connect-ProxmoxServer
-Server <String>
-ApiToken <String>
-ApiTokenSecret <SecureString>
[-Port <Int32>]
[-UseSSL <Boolean>]
[-SkipCertificateValidation <Boolean>]
[-Timeout <Int32>]
[<CommonParameters>]
```
## Description
The `Connect-ProxmoxServer` cmdlet establishes a connection to a Proxmox VE server. This connection is required for all other cmdlets in the PSProxmox module.
## Parameters
### -Server
The hostname or IP address of the Proxmox VE server.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Username
The username to use for authentication.
```yaml
Type: String
Parameter Sets: UsernamePassword
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Password
The password to use for authentication.
```yaml
Type: SecureString
Parameter Sets: UsernamePassword
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Credential
The credential object to use for authentication.
```yaml
Type: PSCredential
Parameter Sets: Credential
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ApiToken
The API token to use for authentication.
```yaml
Type: String
Parameter Sets: ApiToken
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ApiTokenSecret
The API token secret to use for authentication.
```yaml
Type: SecureString
Parameter Sets: ApiToken
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Realm
The authentication realm to use. Default is "pam".
```yaml
Type: String
Parameter Sets: UsernamePassword, Credential
Aliases:
Required: False
Position: Named
Default value: pam
Accept pipeline input: False
Accept wildcard characters: False
```
### -Port
The port to use for the connection. Default is 8006.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 8006
Accept pipeline input: False
Accept wildcard characters: False
```
### -UseSSL
Whether to use SSL for the connection. Default is $true.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
```
### -SkipCertificateValidation
Whether to skip SSL certificate validation. Default is $false.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Timeout
The timeout in seconds for the connection. Default is 30.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 30
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### PSProxmox.Session.ProxmoxConnection
## Notes
- This cmdlet must be called before using any other cmdlets in the PSProxmox module.
- The connection object is returned and should be stored in a variable for use with other cmdlets.
- If you use the `-SkipCertificateValidation` parameter, the SSL certificate validation will be skipped, which is not recommended for production environments.
## Examples
### Example 1: Connect to a Proxmox VE server using username and password
```powershell
$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam"
```
This example connects to a Proxmox VE server using a username and password.
### Example 2: Connect to a Proxmox VE server using a credential object
```powershell
$credential = Get-Credential
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam"
```
This example connects to a Proxmox VE server using a credential object.
### Example 3: Connect to a Proxmox VE server using an API token
```powershell
$secureSecret = ConvertTo-SecureString "secret" -AsPlainText -Force
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -ApiToken "root@pam!token" -ApiTokenSecret $secureSecret
```
This example connects to a Proxmox VE server using an API token.
### Example 4: Connect to a Proxmox VE server with SSL certificate validation disabled
```powershell
$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam" -SkipCertificateValidation $true
```
This example connects to a Proxmox VE server with SSL certificate validation disabled.
## Related Links
- [Disconnect-ProxmoxServer](Disconnect-ProxmoxServer.md)
- [Get-ProxmoxVM](Get-ProxmoxVM.md)
- [Get-ProxmoxNode](Get-ProxmoxNode.md)
+151
View File
@@ -0,0 +1,151 @@
# Get-ProxmoxVM
Gets virtual machines from Proxmox VE.
## Syntax
```powershell
Get-ProxmoxVM
-Connection <ProxmoxConnection>
[-Node <String>]
[-VMID <Int32>]
[-RawJson]
[<CommonParameters>]
```
## Description
The `Get-ProxmoxVM` cmdlet retrieves virtual machines from Proxmox VE. You can retrieve all VMs, VMs on a specific node, or a specific VM by ID.
## Parameters
### -Connection
The connection to the Proxmox VE server.
```yaml
Type: ProxmoxConnection
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Node
The node to get VMs from. If not specified, VMs from all nodes will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VMID
The ID of the VM to get. If not specified, all VMs will be returned.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -RawJson
Whether to return the raw JSON response instead of parsed objects.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### PSProxmox.Models.ProxmoxVM
### System.String
## Notes
- This cmdlet requires a connection to a Proxmox VE server. Use `Connect-ProxmoxServer` to establish a connection.
- If the `-RawJson` parameter is specified, the raw JSON response will be returned instead of parsed objects.
- If the `-VMID` parameter is specified and the VM is not found, an error will be thrown.
## Examples
### Example 1: Get all VMs
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vms = Get-ProxmoxVM -Connection $connection
```
This example gets all VMs from all nodes.
### Example 2: Get VMs on a specific node
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vms = Get-ProxmoxVM -Connection $connection -Node "pve1"
```
This example gets all VMs on the node "pve1".
### Example 3: Get a specific VM by ID
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = Get-ProxmoxVM -Connection $connection -VMID 100
```
This example gets the VM with ID 100.
### Example 4: Get the raw JSON response
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$json = Get-ProxmoxVM -Connection $connection -RawJson
```
This example gets the raw JSON response for all VMs.
## Related Links
- [Connect-ProxmoxServer](Connect-ProxmoxServer.md)
- [New-ProxmoxVM](New-ProxmoxVM.md)
- [Remove-ProxmoxVM](Remove-ProxmoxVM.md)
- [Start-ProxmoxVM](Start-ProxmoxVM.md)
- [Stop-ProxmoxVM](Stop-ProxmoxVM.md)
- [Restart-ProxmoxVM](Restart-ProxmoxVM.md)
+353
View File
@@ -0,0 +1,353 @@
# New-ProxmoxVM
Creates a new virtual machine in Proxmox VE.
## Syntax
```powershell
New-ProxmoxVM
-Connection <ProxmoxConnection>
-Node <String>
-Name <String>
[-VMID <Int32>]
[-Memory <Int32>]
[-Cores <Int32>]
[-Sockets <Int32>]
[-DiskSize <Int32>]
[-Storage <String>]
[-OSType <String>]
[-NetworkModel <String>]
[-NetworkBridge <String>]
[-Description <String>]
[-Start]
[<CommonParameters>]
```
```powershell
New-ProxmoxVM
-Connection <ProxmoxConnection>
-Node <String>
-Builder <ProxmoxVMBuilder>
[<CommonParameters>]
```
## Description
The `New-ProxmoxVM` cmdlet creates a new virtual machine in Proxmox VE. You can specify the VM parameters directly or use a VM builder object.
## Parameters
### -Connection
The connection to the Proxmox VE server.
```yaml
Type: ProxmoxConnection
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Node
The node to create the VM on.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Name
The name of the VM to create.
```yaml
Type: String
Parameter Sets: Direct
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VMID
The VM ID. If not specified, the next available ID will be used.
```yaml
Type: Int32
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Memory
The amount of memory in MB.
```yaml
Type: Int32
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: 512
Accept pipeline input: False
Accept wildcard characters: False
```
### -Cores
The number of CPU cores.
```yaml
Type: Int32
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
```
### -Sockets
The number of CPU sockets.
```yaml
Type: Int32
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
```
### -DiskSize
The disk size in GB.
```yaml
Type: Int32
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: 8
Accept pipeline input: False
Accept wildcard characters: False
```
### -Storage
The storage location for the disk.
```yaml
Type: String
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: local-lvm
Accept pipeline input: False
Accept wildcard characters: False
```
### -OSType
The operating system type.
```yaml
Type: String
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: l26
Accept pipeline input: False
Accept wildcard characters: False
```
### -NetworkModel
The network interface model.
```yaml
Type: String
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: virtio
Accept pipeline input: False
Accept wildcard characters: False
```
### -NetworkBridge
The network bridge.
```yaml
Type: String
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: vmbr0
Accept pipeline input: False
Accept wildcard characters: False
```
### -Description
The description of the VM.
```yaml
Type: String
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Start
Whether to start the VM after creation.
```yaml
Type: SwitchParameter
Parameter Sets: Direct
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Builder
A VM builder object containing the VM configuration.
```yaml
Type: ProxmoxVMBuilder
Parameter Sets: Builder
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### PSProxmox.Models.ProxmoxVM
## Notes
- This cmdlet requires a connection to a Proxmox VE server. Use `Connect-ProxmoxServer` to establish a connection.
- If the `-VMID` parameter is not specified, the next available ID will be used.
- If the `-Start` parameter is specified, the VM will be started after creation.
- You can use the `New-ProxmoxVMBuilder` cmdlet to create a VM builder object for more complex VM configurations.
## Examples
### Example 1: Create a basic VM
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Start
```
This example creates a new VM with 2 GB of memory, 2 CPU cores, and a 32 GB disk, and starts it.
### Example 2: Create a VM using a builder
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$builder = New-ProxmoxVMBuilder -Name "web-server"
$builder.WithMemory(4096)
.WithCores(2)
.WithDisk(50, "local-lvm")
.WithNetwork("virtio", "vmbr0")
.WithIPConfig("192.168.1.10/24", "192.168.1.1")
.WithStart($true)
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Builder $builder
```
This example creates a new VM using a builder object with 4 GB of memory, 2 CPU cores, a 50 GB disk, and a static IP address, and starts it.
### Example 3: Create a VM with a specific ID
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -VMID 100 -Memory 2048 -Cores 2 -DiskSize 32
```
This example creates a new VM with ID 100.
### Example 4: Create a VM with a description
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Description "Test VM for development"
```
This example creates a new VM with a description.
## Related Links
- [Connect-ProxmoxServer](Connect-ProxmoxServer.md)
- [Get-ProxmoxVM](Get-ProxmoxVM.md)
- [Remove-ProxmoxVM](Remove-ProxmoxVM.md)
- [Start-ProxmoxVM](Start-ProxmoxVM.md)
- [Stop-ProxmoxVM](Stop-ProxmoxVM.md)
- [Restart-ProxmoxVM](Restart-ProxmoxVM.md)
- [New-ProxmoxVMBuilder](New-ProxmoxVMBuilder.md)
+389
View File
@@ -0,0 +1,389 @@
# New-ProxmoxVMFromTemplate
Creates a new virtual machine from a template in Proxmox VE.
## Syntax
```powershell
New-ProxmoxVMFromTemplate
-Connection <ProxmoxConnection>
-Node <String>
-TemplateName <String>
-Name <String>
[-VMID <Int32>]
[-Memory <Int32>]
[-Cores <Int32>]
[-DiskSize <Int32>]
[-Storage <String>]
[-NetworkModel <String>]
[-NetworkBridge <String>]
[-Description <String>]
[-IPPool <String>]
[-Start]
[<CommonParameters>]
```
```powershell
New-ProxmoxVMFromTemplate
-Connection <ProxmoxConnection>
-Node <String>
-TemplateName <String>
-Prefix <String>
-Count <Int32>
[-StartIndex <Int32>]
[-Memory <Int32>]
[-Cores <Int32>]
[-DiskSize <Int32>]
[-Storage <String>]
[-NetworkModel <String>]
[-NetworkBridge <String>]
[-Description <String>]
[-IPPool <String>]
[-Start]
[<CommonParameters>]
```
## Description
The `New-ProxmoxVMFromTemplate` cmdlet creates a new virtual machine from a template in Proxmox VE. You can create a single VM or multiple VMs with a prefix and counter.
## Parameters
### -Connection
The connection to the Proxmox VE server.
```yaml
Type: ProxmoxConnection
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Node
The node to create the VM on.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -TemplateName
The name of the template to use.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Name
The name of the VM to create.
```yaml
Type: String
Parameter Sets: SingleVM
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Prefix
The prefix for the VM names when creating multiple VMs.
```yaml
Type: String
Parameter Sets: MultipleVMs
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Count
The number of VMs to create.
```yaml
Type: Int32
Parameter Sets: MultipleVMs
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -StartIndex
The starting index for the VM names when creating multiple VMs.
```yaml
Type: Int32
Parameter Sets: MultipleVMs
Aliases:
Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
```
### -VMID
The VM ID. If not specified, the next available ID will be used.
```yaml
Type: Int32
Parameter Sets: SingleVM
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Memory
The amount of memory in MB. If specified, overrides the template value.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Cores
The number of CPU cores. If specified, overrides the template value.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DiskSize
The disk size in GB. If specified, overrides the template value.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Storage
The storage location for the disk. If specified, overrides the template value.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -NetworkModel
The network interface model. If specified, overrides the template value.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -NetworkBridge
The network bridge. If specified, overrides the template value.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Description
The description of the VM. If specified, overrides the template value.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -IPPool
The IP pool to use for assigning an IP address.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Start
Whether to start the VM after creation.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### PSProxmox.Models.ProxmoxVM
## Notes
- This cmdlet requires a connection to a Proxmox VE server. Use `Connect-ProxmoxServer` to establish a connection.
- If the `-VMID` parameter is not specified, the next available ID will be used.
- If the `-Start` parameter is specified, the VM will be started after creation.
- If the `-IPPool` parameter is specified, an IP address will be assigned from the specified pool.
- When creating multiple VMs, the names will be in the format `{Prefix}{StartIndex + i}` where `i` is the index of the VM (0 to Count-1).
## Examples
### Example 1: Create a VM from a template
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" -Name "web01" -Start
```
This example creates a new VM from the "Ubuntu-Template" template and starts it.
### Example 2: Create multiple VMs from a template
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vms = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" -Prefix "web" -Count 3 -Start
```
This example creates three new VMs from the "Ubuntu-Template" template with names "web1", "web2", and "web3", and starts them.
### Example 3: Create a VM from a template with custom settings
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" -Name "web01" -Memory 4096 -Cores 2 -DiskSize 50 -Start
```
This example creates a new VM from the "Ubuntu-Template" template with 4 GB of memory, 2 CPU cores, and a 50 GB disk, and starts it.
### Example 4: Create a VM from a template with an IP from a pool
```powershell
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" -Name "web01" -IPPool "Production" -Start
```
This example creates a new VM from the "Ubuntu-Template" template, assigns an IP address from the "Production" pool, and starts it.
## Related Links
- [Connect-ProxmoxServer](Connect-ProxmoxServer.md)
- [Get-ProxmoxVM](Get-ProxmoxVM.md)
- [New-ProxmoxVM](New-ProxmoxVM.md)
- [Get-ProxmoxVMTemplate](Get-ProxmoxVMTemplate.md)
- [New-ProxmoxVMTemplate](New-ProxmoxVMTemplate.md)
- [New-ProxmoxIPPool](New-ProxmoxIPPool.md)
+81
View File
@@ -0,0 +1,81 @@
# PSProxmox Cmdlets
This directory contains documentation for all cmdlets in the PSProxmox module.
## Cmdlet Categories
- [Session Management](#session-management)
- [VM Management](#vm-management)
- [Storage Management](#storage-management)
- [Network Management](#network-management)
- [User and Role Management](#user-and-role-management)
- [SDN Management](#sdn-management)
- [Cluster Management](#cluster-management)
- [Template Management](#template-management)
- [IP Management](#ip-management)
## Session Management
- [Connect-ProxmoxServer](Connect-ProxmoxServer.md) - Connects to a Proxmox VE server
- [Disconnect-ProxmoxServer](Disconnect-ProxmoxServer.md) - Disconnects from a Proxmox VE server
## VM Management
- [Get-ProxmoxVM](Get-ProxmoxVM.md) - Gets virtual machines from Proxmox VE
- [New-ProxmoxVM](New-ProxmoxVM.md) - Creates a new virtual machine in Proxmox VE
- [Remove-ProxmoxVM](Remove-ProxmoxVM.md) - Removes a virtual machine from Proxmox VE
- [Start-ProxmoxVM](Start-ProxmoxVM.md) - Starts a virtual machine in Proxmox VE
- [Stop-ProxmoxVM](Stop-ProxmoxVM.md) - Stops a virtual machine in Proxmox VE
- [Restart-ProxmoxVM](Restart-ProxmoxVM.md) - Restarts a virtual machine in Proxmox VE
## Storage Management
- [Get-ProxmoxStorage](Get-ProxmoxStorage.md) - Gets storage from Proxmox VE
- [New-ProxmoxStorage](New-ProxmoxStorage.md) - Creates a new storage in Proxmox VE
- [Remove-ProxmoxStorage](Remove-ProxmoxStorage.md) - Removes a storage from Proxmox VE
## Network Management
- [Get-ProxmoxNetwork](Get-ProxmoxNetwork.md) - Gets network interfaces from Proxmox VE
- [New-ProxmoxNetwork](New-ProxmoxNetwork.md) - Creates a new network interface in Proxmox VE
- [Remove-ProxmoxNetwork](Remove-ProxmoxNetwork.md) - Removes a network interface from Proxmox VE
## User and Role Management
- [Get-ProxmoxUser](Get-ProxmoxUser.md) - Gets users from Proxmox VE
- [New-ProxmoxUser](New-ProxmoxUser.md) - Creates a new user in Proxmox VE
- [Remove-ProxmoxUser](Remove-ProxmoxUser.md) - Removes a user from Proxmox VE
- [Get-ProxmoxRole](Get-ProxmoxRole.md) - Gets roles from Proxmox VE
- [New-ProxmoxRole](New-ProxmoxRole.md) - Creates a new role in Proxmox VE
- [Remove-ProxmoxRole](Remove-ProxmoxRole.md) - Removes a role from Proxmox VE
## SDN Management
- [Get-ProxmoxSDNZone](Get-ProxmoxSDNZone.md) - Gets SDN zones from Proxmox VE
- [New-ProxmoxSDNZone](New-ProxmoxSDNZone.md) - Creates a new SDN zone in Proxmox VE
- [Remove-ProxmoxSDNZone](Remove-ProxmoxSDNZone.md) - Removes an SDN zone from Proxmox VE
- [Get-ProxmoxSDNVnet](Get-ProxmoxSDNVnet.md) - Gets SDN VNets from Proxmox VE
- [New-ProxmoxSDNVnet](New-ProxmoxSDNVnet.md) - Creates a new SDN VNet in Proxmox VE
- [Remove-ProxmoxSDNVnet](Remove-ProxmoxSDNVnet.md) - Removes an SDN VNet from Proxmox VE
## Cluster Management
- [Get-ProxmoxCluster](Get-ProxmoxCluster.md) - Gets cluster information from Proxmox VE
- [Join-ProxmoxCluster](Join-ProxmoxCluster.md) - Joins a node to a Proxmox VE cluster
- [Leave-ProxmoxCluster](Leave-ProxmoxCluster.md) - Removes a node from a Proxmox VE cluster
- [Get-ProxmoxClusterBackup](Get-ProxmoxClusterBackup.md) - Gets cluster backups from Proxmox VE
- [New-ProxmoxClusterBackup](New-ProxmoxClusterBackup.md) - Creates a new cluster backup in Proxmox VE
- [Restore-ProxmoxClusterBackup](Restore-ProxmoxClusterBackup.md) - Restores a cluster backup in Proxmox VE
## Template Management
- [Get-ProxmoxVMTemplate](Get-ProxmoxVMTemplate.md) - Gets VM templates from Proxmox VE
- [New-ProxmoxVMTemplate](New-ProxmoxVMTemplate.md) - Creates a new VM template in Proxmox VE
- [Remove-ProxmoxVMTemplate](Remove-ProxmoxVMTemplate.md) - Removes a VM template from Proxmox VE
- [New-ProxmoxVMFromTemplate](New-ProxmoxVMFromTemplate.md) - Creates a new VM from a template in Proxmox VE
## IP Management
- [New-ProxmoxIPPool](New-ProxmoxIPPool.md) - Creates a new IP pool
- [Get-ProxmoxIPPool](Get-ProxmoxIPPool.md) - Gets IP pools
- [Clear-ProxmoxIPPool](Clear-ProxmoxIPPool.md) - Clears an IP pool
@@ -0,0 +1,39 @@
# Advanced-MultipleVMsFromTemplate.ps1
# This script demonstrates how to create multiple VMs from a template using the PSProxmox module.
# Import the PSProxmox module
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"
# Method 1: Create multiple VMs from a template with default settings
$vms = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" `
-Prefix "web" -Count 3 -Start
# Display the VM information
$vms
# Method 2: Create multiple VMs from a template with custom settings
$vms = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" `
-Prefix "db" -Count 2 -StartIndex 1 -Memory 4096 -Cores 2 -DiskSize 50 -Start
# Display the VM information
$vms
# Method 3: Create multiple VMs from a template with IP addresses from a pool
# First, create an IP pool if it doesn't exist
if (-not (Get-ProxmoxIPPool -Name "Production")) {
New-ProxmoxIPPool -Name "Production" -CIDR "192.168.1.0/24" -ExcludeIPs "192.168.1.1", "192.168.1.254"
}
# Create the VMs with IP addresses from the pool
$vms = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" `
-Prefix "app" -Count 5 -IPPool "Production" -Start
# Display the VM information
$vms
# Disconnect from the server when done
Disconnect-ProxmoxServer -Connection $connection
+55
View File
@@ -0,0 +1,55 @@
# Advanced-VMBuilder.ps1
# This script demonstrates how to create a VM using the builder pattern with the PSProxmox module.
# Import the PSProxmox module
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"
# Create a VM builder
$builder = New-ProxmoxVMBuilder -Name "web-server"
# Configure the VM using the builder pattern
$builder.WithMemory(4096) # 4 GB of memory
.WithCores(2) # 2 CPU cores
.WithSockets(1) # 1 CPU socket
.WithDisk(50, "local-lvm") # 50 GB disk on local-lvm storage
.WithNetwork("virtio", "vmbr0") # virtio network on vmbr0 bridge
.WithIPConfig("192.168.1.10/24", "192.168.1.1") # Static IP configuration
.WithDescription("Web server for production") # Description
.WithStart($true) # Start the VM after creation
# Create the VM using the builder
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Builder $builder
# Display the VM information
$vm
# Create another VM with a more complex configuration
$builder = New-ProxmoxVMBuilder -Name "db-server"
# Configure the VM using the builder pattern
$builder.WithMemory(8192) # 8 GB of memory
.WithCores(4) # 4 CPU cores
.WithSockets(2) # 2 CPU sockets
.WithDisk(100, "local-lvm") # 100 GB primary disk on local-lvm storage
.WithAdditionalDisk(200, "local-lvm") # 200 GB additional disk on local-lvm storage
.WithNetwork("virtio", "vmbr0") # virtio network on vmbr0 bridge
.WithAdditionalNetwork("virtio", "vmbr1") # Additional network interface on vmbr1
.WithIPConfig("192.168.1.20/24", "192.168.1.1") # Static IP configuration for first interface
.WithCPUType("host") # CPU type
.WithVGA("std") # VGA type
.WithBoot("order=scsi0;net0") # Boot order
.WithDescription("Database server for production") # Description
.WithStart($true) # Start the VM after creation
# Create the VM using the builder
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Builder $builder
# Display the VM information
$vm
# Disconnect from the server when done
Disconnect-ProxmoxServer -Connection $connection
+27
View File
@@ -0,0 +1,27 @@
# Basic-Connection.ps1
# This script demonstrates how to connect to a Proxmox VE server using the PSProxmox module.
# Import the PSProxmox module
Import-Module PSProxmox
# Method 1: Connect using username and password
$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam"
# Method 2: Connect using a credential object
$credential = Get-Credential -Message "Enter your Proxmox VE credentials"
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam"
# Method 3: Connect using an API token
$secureSecret = ConvertTo-SecureString "secret" -AsPlainText -Force
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -ApiToken "root@pam!token" -ApiTokenSecret $secureSecret
# Method 4: Connect with SSL certificate validation disabled (not recommended for production)
$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam" -SkipCertificateValidation $true
# Display the connection information
$connection
# Disconnect from the server when done
Disconnect-ProxmoxServer -Connection $connection
+34
View File
@@ -0,0 +1,34 @@
# Basic-CreateVM.ps1
# This script demonstrates how to create a new VM using the PSProxmox module.
# Import the PSProxmox module
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"
# Method 1: Create a basic VM
$vm = New-ProxmoxVM -Connection $connection -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" `
-Memory 4096 -Cores 2 -Sockets 1 -DiskSize 50 -Storage "local-lvm" `
-OSType "l26" -NetworkModel "virtio" -NetworkBridge "vmbr0" `
-Description "Web server for testing" -Start
# Display the VM information
$vm
# Method 3: Create a VM with a specific ID
$vm = New-ProxmoxVM -Connection $connection -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
Disconnect-ProxmoxServer -Connection $connection
+43
View File
@@ -0,0 +1,43 @@
# Cluster-CreateBackup.ps1
# This script demonstrates how to create a cluster backup using the PSProxmox module.
# Import the PSProxmox module
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"
# Method 1: Create a cluster backup with default settings
$backup = New-ProxmoxClusterBackup -Connection $connection
# Display the backup information
$backup
# Method 2: Create a cluster backup with compression
$backup = New-ProxmoxClusterBackup -Connection $connection -Compress
# Display the backup information
$backup
# Method 3: Create a cluster backup and wait for it to complete
$backup = New-ProxmoxClusterBackup -Connection $connection -Compress -Wait -Timeout 600
# Display the backup information
$backup
# Method 4: Get all cluster backups
$backups = Get-ProxmoxClusterBackup -Connection $connection
# Display the backups
$backups
# Method 5: Get a specific cluster backup
$backupID = $backup.BackupID
$specificBackup = Get-ProxmoxClusterBackup -Connection $connection -BackupID $backupID
# Display the specific backup
$specificBackup
# Disconnect from the server when done
Disconnect-ProxmoxServer -Connection $connection
+69
View File
@@ -0,0 +1,69 @@
# PSProxmox Examples
This directory contains example scripts for the PSProxmox module.
## Basic Examples
- [Connect to a Proxmox VE server](Basic-Connection.ps1)
- [Get information about VMs](Basic-GetVMs.ps1)
- [Create a new VM](Basic-CreateVM.ps1)
- [Start, stop, and restart VMs](Basic-VMPowerManagement.ps1)
- [Remove a VM](Basic-RemoveVM.ps1)
## Advanced Examples
- [Create a VM using the builder pattern](Advanced-VMBuilder.ps1)
- [Create multiple VMs from a template](Advanced-MultipleVMsFromTemplate.ps1)
- [Create a VM with a static IP address](Advanced-VMWithStaticIP.ps1)
- [Create a VM with multiple disks](Advanced-VMWithMultipleDisks.ps1)
- [Create a VM with multiple network interfaces](Advanced-VMWithMultipleNetworks.ps1)
## Cluster Management Examples
- [Join a node to a cluster](Cluster-JoinNode.ps1)
- [Remove a node from a cluster](Cluster-RemoveNode.ps1)
- [Create a cluster backup](Cluster-CreateBackup.ps1)
- [Restore a cluster backup](Cluster-RestoreBackup.ps1)
## Storage Management Examples
- [Get information about storage](Storage-GetStorage.ps1)
- [Create a new storage](Storage-CreateStorage.ps1)
- [Remove a storage](Storage-RemoveStorage.ps1)
## Network Management Examples
- [Get information about network interfaces](Network-GetInterfaces.ps1)
- [Create a new network interface](Network-CreateInterface.ps1)
- [Remove a network interface](Network-RemoveInterface.ps1)
## User and Role Management Examples
- [Get information about users](User-GetUsers.ps1)
- [Create a new user](User-CreateUser.ps1)
- [Remove a user](User-RemoveUser.ps1)
- [Get information about roles](Role-GetRoles.ps1)
- [Create a new role](Role-CreateRole.ps1)
- [Remove a role](Role-RemoveRole.ps1)
## SDN Management Examples
- [Get information about SDN zones](SDN-GetZones.ps1)
- [Create a new SDN zone](SDN-CreateZone.ps1)
- [Remove an SDN zone](SDN-RemoveZone.ps1)
- [Get information about SDN VNets](SDN-GetVNets.ps1)
- [Create a new SDN VNet](SDN-CreateVNet.ps1)
- [Remove an SDN VNet](SDN-RemoveVNet.ps1)
## Template Management Examples
- [Get information about VM templates](Template-GetTemplates.ps1)
- [Create a new VM template](Template-CreateTemplate.ps1)
- [Remove a VM template](Template-RemoveTemplate.ps1)
- [Create a VM from a template](Template-CreateVMFromTemplate.ps1)
## IP Management Examples
- [Create a new IP pool](IP-CreatePool.ps1)
- [Get information about IP pools](IP-GetPools.ps1)
- [Clear an IP pool](IP-ClearPool.ps1)
+212
View File
@@ -0,0 +1,212 @@
# Cluster Backup and Restore
This guide explains how to backup and restore Proxmox VE clusters using the PSProxmox module.
## Prerequisites
- PSProxmox module installed
- Connection to a Proxmox VE server
- Administrative access to the Proxmox VE cluster
## Cluster Backups
Cluster backups in Proxmox VE contain the cluster configuration, including:
- Cluster configuration
- User and role configuration
- Storage configuration
- Network configuration
- Firewall configuration
- HA configuration
They do not include VM data or container data.
## Creating Cluster Backups
### Basic Backup
To create a basic cluster backup:
```powershell
# Connect to the Proxmox VE server
$credential = Get-Credential
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam"
# Create a cluster backup
$backup = New-ProxmoxClusterBackup -Connection $connection
```
### Backup with Compression
To create a compressed cluster backup:
```powershell
$backup = New-ProxmoxClusterBackup -Connection $connection -Compress
```
### Backup and Wait for Completion
To create a backup and wait for it to complete:
```powershell
$backup = New-ProxmoxClusterBackup -Connection $connection -Compress -Wait -Timeout 600
```
This will wait up to 10 minutes (600 seconds) for the backup to complete.
## Listing Cluster Backups
To list all cluster backups:
```powershell
$backups = Get-ProxmoxClusterBackup -Connection $connection
```
To get a specific backup by ID:
```powershell
$backupID = "vzdump-cluster-2023_04_28-12_00_00.vma.lzo"
$backup = Get-ProxmoxClusterBackup -Connection $connection -BackupID $backupID
```
## Restoring Cluster Backups
### Basic Restore
To restore a cluster backup:
```powershell
$backupID = "vzdump-cluster-2023_04_28-12_00_00.vma.lzo"
Restore-ProxmoxClusterBackup -Connection $connection -BackupID $backupID -Force
```
The `-Force` parameter is required to confirm the restore operation.
### Restore and Wait for Completion
To restore a backup and wait for it to complete:
```powershell
Restore-ProxmoxClusterBackup -Connection $connection -BackupID $backupID -Force -Wait -Timeout 600
```
This will wait up to 10 minutes (600 seconds) for the restore to complete.
## Best Practices
### Backup Frequency
- Create regular backups of your cluster configuration
- Automate backup creation using scheduled tasks
- Keep multiple backups to ensure you can restore to different points in time
### Backup Verification
- Verify that backups are created successfully
- Test restoring backups in a non-production environment
- Document the backup and restore procedures
### Backup Storage
- Store backups in a secure location
- Consider storing backups off-site
- Implement backup rotation to manage storage space
## Example: Automated Backup Script
Here's an example script for automated cluster backups:
```powershell
# Automated-Cluster-Backup.ps1
# This script creates a cluster backup and logs the result
# Import the PSProxmox module
Import-Module PSProxmox
# Connect to the Proxmox VE server
$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam"
# Create a timestamp for the log
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
try {
# Create a cluster backup
$backup = New-ProxmoxClusterBackup -Connection $connection -Compress -Wait -Timeout 600
# Log the successful backup
$logMessage = "$timestamp - Backup created successfully: $($backup.BackupID)"
Add-Content -Path "C:\Logs\ProxmoxBackup.log" -Value $logMessage
}
catch {
# Log the error
$logMessage = "$timestamp - Backup failed: $($_.Exception.Message)"
Add-Content -Path "C:\Logs\ProxmoxBackup.log" -Value $logMessage
}
finally {
# Disconnect from the server
Disconnect-ProxmoxServer -Connection $connection
}
```
## Example: Restore Script
Here's an example script for restoring a cluster backup:
```powershell
# Restore-Cluster-Backup.ps1
# This script restores a cluster backup
# Import the PSProxmox module
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"
# Get the latest backup
$latestBackup = Get-ProxmoxClusterBackup -Connection $connection | Sort-Object -Property Time -Descending | Select-Object -First 1
if ($latestBackup) {
Write-Host "Latest backup: $($latestBackup.BackupID) from $(Get-Date -Date $latestBackup.Time -Format 'yyyy-MM-dd HH:mm:ss')"
# Confirm the restore operation
$confirm = Read-Host "Do you want to restore this backup? (y/n)"
if ($confirm -eq "y") {
# Restore the backup
Restore-ProxmoxClusterBackup -Connection $connection -BackupID $latestBackup.BackupID -Force -Wait -Timeout 600
Write-Host "Backup restored successfully"
}
else {
Write-Host "Restore operation cancelled"
}
}
else {
Write-Host "No backups found"
}
# Disconnect from the server
Disconnect-ProxmoxServer -Connection $connection
```
## Troubleshooting
### Backup Creation Fails
If backup creation fails, check:
- The user has sufficient permissions
- There is enough disk space
- The storage is accessible
- The cluster is healthy
### Restore Operation Fails
If restore operation fails, check:
- The backup file exists and is accessible
- The backup file is not corrupted
- The user has sufficient permissions
- The cluster is in a state that allows restore operations
## Next Steps
Now that you know how to backup and restore Proxmox VE clusters, you can proceed to the [High Availability](High-Availability.md) guide to learn how to configure high availability for your cluster.
+145
View File
@@ -0,0 +1,145 @@
# Creating VMs
This guide explains how to create virtual machines using the PSProxmox module.
## Prerequisites
- PSProxmox module installed
- Connection to a Proxmox VE server
## Basic VM Creation
The simplest way to create a VM is to use the `New-ProxmoxVM` cmdlet with basic parameters:
```powershell
# Connect to the Proxmox VE server
$credential = Get-Credential
$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam"
# Create a basic VM
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Start
```
This creates a VM with the following specifications:
- Name: test-vm
- Memory: 2 GB
- CPU: 2 cores
- Disk: 32 GB
- The VM will be started after creation
## Advanced VM Creation
For more control over the VM configuration, you can specify additional parameters:
```powershell
$vm = New-ProxmoxVM -Connection $connection -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
```
This creates a VM with more specific configuration:
- Name: web-server
- Memory: 4 GB
- CPU: 2 cores, 1 socket
- Disk: 50 GB on local-lvm storage
- OS Type: Linux 2.6+ kernel
- Network: virtio model on vmbr0 bridge
- Description: "Web server for testing"
- The VM will be started after creation
## Using the VM Builder Pattern
For complex VM configurations, you can use the VM builder pattern:
```powershell
# Create a VM builder
$builder = New-ProxmoxVMBuilder -Name "db-server"
# Configure the VM using the builder pattern
$builder.WithMemory(8192) # 8 GB of memory
.WithCores(4) # 4 CPU cores
.WithSockets(2) # 2 CPU sockets
.WithDisk(100, "local-lvm") # 100 GB primary disk on local-lvm storage
.WithAdditionalDisk(200, "local-lvm") # 200 GB additional disk on local-lvm storage
.WithNetwork("virtio", "vmbr0") # virtio network on vmbr0 bridge
.WithAdditionalNetwork("virtio", "vmbr1") # Additional network interface on vmbr1
.WithIPConfig("192.168.1.20/24", "192.168.1.1") # Static IP configuration for first interface
.WithCPUType("host") # CPU type
.WithVGA("std") # VGA type
.WithBoot("order=scsi0;net0") # Boot order
.WithDescription("Database server for production") # Description
.WithStart($true) # Start the VM after creation
# Create the VM using the builder
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Builder $builder
```
The builder pattern allows you to:
- Chain configuration methods together
- Configure complex settings like multiple disks and network interfaces
- Set advanced parameters like CPU type, VGA type, and boot order
## Creating VMs from Templates
If you have VM templates, you can create VMs from them using the `New-ProxmoxVMFromTemplate` cmdlet:
```powershell
# Create a VM from a template
$vm = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" -Name "web01" -Start
```
You can also override template settings:
```powershell
# Create a VM from a template with custom settings
$vm = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" `
-Name "web01" -Memory 4096 -Cores 2 -DiskSize 50 -Start
```
## Creating Multiple VMs from Templates
You can create multiple VMs from a template in one operation:
```powershell
# Create multiple VMs from a template
$vms = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" `
-Prefix "web" -Count 3 -Start
```
This creates three VMs named "web1", "web2", and "web3".
You can also specify a starting index:
```powershell
# Create multiple VMs from a template with a custom starting index
$vms = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" `
-Prefix "web" -Count 3 -StartIndex 10 -Start
```
This creates three VMs named "web10", "web11", and "web12".
## Creating VMs with IP Addresses from a Pool
If you have IP pools configured, you can assign IP addresses from them:
```powershell
# Create a VM with an IP address from a pool
$vm = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" `
-Name "web01" -IPPool "Production" -Start
```
This assigns an IP address from the "Production" pool to the VM.
## Best Practices
- Use descriptive names for your VMs
- Use templates for consistent VM configurations
- Use the builder pattern for complex VM configurations
- Document your VM configurations
- Use IP pools for IP address management
- Test your VM configurations before deploying to production
## Next Steps
Now that you know how to create VMs, you can proceed to the [Managing VMs](Managing-VMs.md) guide to learn how to manage them.
+110
View File
@@ -0,0 +1,110 @@
# Installation Guide
This guide explains how to install the PSProxmox module.
## Prerequisites
- PowerShell 5.1 or later
- Windows PowerShell or PowerShell Core
- .NET Framework 4.7.2 or later (for Windows PowerShell)
- .NET Core 2.0 or later (for PowerShell Core)
## Installation Methods
### Method 1: Install from PowerShell Gallery (Recommended)
The PSProxmox module is available on the PowerShell Gallery. To install it, run the following command:
```powershell
Install-Module -Name PSProxmox -Scope CurrentUser
```
If you want to install it for all users on the system, run the following command with administrative privileges:
```powershell
Install-Module -Name PSProxmox -Scope AllUsers
```
### Method 2: Install from GitHub
You can also install the PSProxmox module directly from GitHub:
1. Download the latest release from the [GitHub repository](https://github.com/freedbygrace/PSProxmox/releases)
2. Extract the ZIP file
3. Run the `Install-PSProxmox.ps1` script included in the package:
```powershell
.\Install-PSProxmox.ps1
```
### Method 3: Manual Installation
You can manually install the PSProxmox module by copying the files to your PowerShell modules directory:
1. Download the latest release from the [GitHub repository](https://github.com/freedbygrace/PSProxmox/releases)
2. Extract the ZIP file
3. Copy the extracted files to a folder named "PSProxmox" in your PowerShell modules directory:
For Windows PowerShell:
```powershell
Copy-Item -Path .\PSProxmox-Dist\* -Destination "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\PSProxmox" -Recurse -Force
```
For PowerShell Core:
```powershell
Copy-Item -Path .\PSProxmox-Dist\* -Destination "$env:USERPROFILE\Documents\PowerShell\Modules\PSProxmox" -Recurse -Force
```
## Verifying the Installation
To verify that the PSProxmox module is installed correctly, run the following command:
```powershell
Get-Module -Name PSProxmox -ListAvailable
```
You should see output similar to the following:
```
Directory: C:\Users\username\Documents\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 2023.04... PSProxmox {Clear-ProxmoxIPPool, Connect-ProxmoxServer, Disconnect-ProxmoxServer, Get-ProxmoxCluster...}
```
## Importing the Module
To import the PSProxmox module into your PowerShell session, run the following command:
```powershell
Import-Module PSProxmox
```
You can verify that the module is imported correctly by running:
```powershell
Get-Command -Module PSProxmox
```
This will list all the cmdlets available in the PSProxmox module.
## Updating the Module
To update the PSProxmox module to the latest version, run the following command:
```powershell
Update-Module -Name PSProxmox
```
## Uninstalling the Module
To uninstall the PSProxmox module, run the following command:
```powershell
Uninstall-Module -Name PSProxmox
```
## Next Steps
Now that you have installed the PSProxmox module, you can proceed to the [Connection Guide](Connection.md) to learn how to connect to a Proxmox VE server.
+47
View File
@@ -0,0 +1,47 @@
# PSProxmox Guides
This directory contains guides for common tasks with the PSProxmox module.
## Getting Started
- [Installation Guide](Installation.md)
- [Connection Guide](Connection.md)
- [Authentication Methods](Authentication.md)
## VM Management
- [Creating VMs](Creating-VMs.md)
- [Managing VMs](Managing-VMs.md)
- [VM Templates](VM-Templates.md)
- [VM Snapshots](VM-Snapshots.md)
- [VM Migration](VM-Migration.md)
## Cluster Management
- [Cluster Setup](Cluster-Setup.md)
- [Cluster Backup and Restore](Cluster-Backup-Restore.md)
- [High Availability](High-Availability.md)
## Storage Management
- [Storage Types](Storage-Types.md)
- [Managing Storage](Managing-Storage.md)
- [Storage Replication](Storage-Replication.md)
## Network Management
- [Network Configuration](Network-Configuration.md)
- [SDN Setup](SDN-Setup.md)
- [Firewall Configuration](Firewall-Configuration.md)
## User Management
- [User and Role Management](User-Role-Management.md)
- [Permissions and ACLs](Permissions-ACLs.md)
- [API Tokens](API-Tokens.md)
## Advanced Topics
- [Automation and Scripting](Automation-Scripting.md)
- [Performance Tuning](Performance-Tuning.md)
- [Troubleshooting](Troubleshooting.md)