diff --git a/.gitignore b/.gitignore index 6716e14..533ab53 100644 --- a/.gitignore +++ b/.gitignore @@ -34,8 +34,8 @@ x86/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ -[Bb]in/ -[Oo]bj/ +PSProxmox/[Bb]in/ +PSProxmox/[Oo]bj/ [Ll]og/ [Ll]ogs/ @@ -46,6 +46,10 @@ bld/ *.tar.gz *.tgz +# Module bin folder (except the DLL) +Module/bin/* +!Module/bin/PSProxmox.dll + # PowerShell module artifacts *.psm1 *.psd1.meta diff --git a/Module/Install-PSProxmox.ps1 b/Module/Install-PSProxmox.ps1 new file mode 100644 index 0000000..7bccb95 --- /dev/null +++ b/Module/Install-PSProxmox.ps1 @@ -0,0 +1,32 @@ +# Install-PSProxmox.ps1 +# This script installs the PSProxmox module to the user's PowerShell modules directory + +# Define the module name +$moduleName = "PSProxmox" + +# Define the destination path +$modulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\$moduleName" +if ($PSVersionTable.PSEdition -eq "Core") { + $modulePath = "$env:USERPROFILE\Documents\PowerShell\Modules\$moduleName" +} + +# Create the module directory if it doesn't exist +if (-not (Test-Path -Path $modulePath)) { + New-Item -Path $modulePath -ItemType Directory -Force | Out-Null + Write-Host "Created module directory: $modulePath" +} + +# Create the bin directory if it doesn't exist +if (-not (Test-Path -Path "$modulePath\bin")) { + New-Item -Path "$modulePath\bin" -ItemType Directory -Force | Out-Null + Write-Host "Created bin directory: $modulePath\bin" +} + +# Copy the module files +Copy-Item -Path "$PSScriptRoot\PSProxmox.psd1" -Destination $modulePath -Force +Copy-Item -Path "$PSScriptRoot\bin\PSProxmox.dll" -Destination "$modulePath\bin" -Force +Copy-Item -Path "$PSScriptRoot\LICENSE" -Destination $modulePath -Force +Copy-Item -Path "$PSScriptRoot\README.md" -Destination $modulePath -Force + +Write-Host "PSProxmox module has been installed to $modulePath" +Write-Host "You can now import the module using: Import-Module $moduleName" diff --git a/Module/LICENSE b/Module/LICENSE new file mode 100644 index 0000000..6fb1a0a --- /dev/null +++ b/Module/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 freedbygrace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/PSProxmox.psd1 b/Module/PSProxmox.psd1 similarity index 98% rename from PSProxmox.psd1 rename to Module/PSProxmox.psd1 index e8d5dad..64f293f 100644 --- a/PSProxmox.psd1 +++ b/Module/PSProxmox.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'PSProxmox.dll' - ModuleVersion = '2023.04.28.1324' + ModuleVersion = '2025.04.28.1934' GUID = 'd24f0894-3d0c-4ef1-a41e-b273c3db86ad' Author = 'PSProxmox Team' CompanyName = 'PSProxmox' @@ -87,3 +87,4 @@ } } } + diff --git a/Module/README.md b/Module/README.md new file mode 100644 index 0000000..f72c555 --- /dev/null +++ b/Module/README.md @@ -0,0 +1,193 @@ +# PSProxmox + +PSProxmox is a PowerShell module for managing Proxmox VE clusters. It provides a comprehensive set of cmdlets for managing virtual machines, storage, networks, users, roles, and more. + +## Installation + +```powershell +# Install from PowerShell Gallery +Install-Module -Name PSProxmox -Scope CurrentUser +``` + +## Getting Started + +### Connecting to a Proxmox VE Server + +```powershell +# Connect using username and password +$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force +$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam" + +# Connect using a credential object +$credential = Get-Credential +$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential $credential -Realm "pam" +``` + +### Managing Virtual Machines + +```powershell +# Get all VMs +$vms = Get-ProxmoxVM -Connection $connection + +# Get a specific VM +$vm = Get-ProxmoxVM -Connection $connection -VMID 100 + +# Create a new VM +$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Start + +# Create a new VM using the builder pattern +$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 + +# Start, stop, and restart VMs +Start-ProxmoxVM -Connection $connection -Node "pve1" -VMID 100 +Stop-ProxmoxVM -Connection $connection -Node "pve1" -VMID 100 +Restart-ProxmoxVM -Connection $connection -Node "pve1" -VMID 100 + +# Remove a VM +Remove-ProxmoxVM -Connection $connection -Node "pve1" -VMID 100 -Confirm:$false +``` + +### Managing Templates + +```powershell +# Create a template from an existing VM +$template = New-ProxmoxVMTemplate -Connection $connection -VMID 100 -Name "Ubuntu-Template" -Description "Ubuntu 20.04 Template" + +# Get all templates +$templates = Get-ProxmoxVMTemplate + +# Create a VM from a template +$vm = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" -Name "web01" -Start + +# Create multiple VMs from a template +$vms = New-ProxmoxVMFromTemplate -Connection $connection -Node "pve1" -TemplateName "Ubuntu-Template" -Prefix "web" -Count 3 -Start +``` + +### Managing Storage + +```powershell +# Get all storage +$storage = Get-ProxmoxStorage -Connection $connection + +# Get storage on a specific node +$storage = Get-ProxmoxStorage -Connection $connection -Node "pve1" + +# Create a new storage +$storage = New-ProxmoxStorage -Connection $connection -Name "backup" -Type "dir" -Path "/mnt/backup" -Content "backup,iso" + +# Remove a storage +Remove-ProxmoxStorage -Connection $connection -Name "backup" -Confirm:$false +``` + +### Managing Networks + +```powershell +# Get all network interfaces on a node +$networks = Get-ProxmoxNetwork -Connection $connection -Node "pve1" + +# Create a new bridge interface +$network = New-ProxmoxNetwork -Connection $connection -Node "pve1" -Interface "vmbr1" -Type "bridge" -BridgePorts "eth1" -Method "static" -Address "192.168.2.1" -Netmask "255.255.255.0" -Autostart + +# Remove a network interface +Remove-ProxmoxNetwork -Connection $connection -Node "pve1" -Interface "vmbr1" -Confirm:$false +``` + +### Managing Users and Roles + +```powershell +# Get all users +$users = Get-ProxmoxUser -Connection $connection + +# Create a new user +$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force +$user = New-ProxmoxUser -Connection $connection -Username "john" -Realm "pam" -Password $securePassword -FirstName "John" -LastName "Doe" -Email "john.doe@example.com" + +# Remove a user +Remove-ProxmoxUser -Connection $connection -UserID "john@pam" -Confirm:$false + +# Get all roles +$roles = Get-ProxmoxRole -Connection $connection + +# Create a new role +$role = New-ProxmoxRole -Connection $connection -RoleID "Developer" -Privileges "VM.Allocate", "VM.Config.Disk", "VM.Config.CPU", "VM.PowerMgmt" + +# Remove a role +Remove-ProxmoxRole -Connection $connection -RoleID "Developer" -Confirm:$false +``` + +### Managing SDN + +```powershell +# Get all SDN zones +$zones = Get-ProxmoxSDNZone -Connection $connection + +# Create a new SDN zone +$zone = New-ProxmoxSDNZone -Connection $connection -Zone "zone1" -Type "vlan" -Bridge "vmbr0" + +# Remove an SDN zone +Remove-ProxmoxSDNZone -Connection $connection -Zone "zone1" -Confirm:$false + +# Get all SDN VNets +$vnets = Get-ProxmoxSDNVnet -Connection $connection + +# Create a new SDN VNet +$vnet = New-ProxmoxSDNVnet -Connection $connection -VNet "vnet1" -Zone "zone1" -IPv4 "192.168.1.0/24" -Gateway "192.168.1.1" + +# Remove an SDN VNet +Remove-ProxmoxSDNVnet -Connection $connection -VNet "vnet1" -Confirm:$false +``` + +### Managing Clusters + +```powershell +# Get cluster information +$cluster = Get-ProxmoxCluster -Connection $connection + +# Join a node to a cluster +$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force +Join-ProxmoxCluster -Connection $connection -ClusterName "cluster1" -HostName "pve1" -Password $securePassword + +# Leave a cluster +Leave-ProxmoxCluster -Connection $connection -Force + +# Create a cluster backup +$backup = New-ProxmoxClusterBackup -Connection $connection -Compress -Wait + +# Restore a cluster backup +Restore-ProxmoxClusterBackup -Connection $connection -BackupID "vzdump-cluster-2023_04_28-12_00_00.vma.lzo" -Force -Wait +``` + +### Managing IP Addresses + +```powershell +# Create a new IP pool +$pool = New-ProxmoxIPPool -Name "Production" -CIDR "192.168.1.0/24" -ExcludeIPs "192.168.1.1", "192.168.1.254" + +# Get all IP pools +$pools = Get-ProxmoxIPPool + +# Get a specific IP pool +$pool = Get-ProxmoxIPPool -Name "Production" + +# Clear an IP pool +Clear-ProxmoxIPPool -Name "Production" +``` + +## Disconnecting + +```powershell +# Disconnect from the server +Disconnect-ProxmoxServer -Connection $connection +``` + +## License + +This project is licensed under the MIT License - see the LICENSE file for details. diff --git a/PSProxmox.zip b/PSProxmox.zip deleted file mode 100644 index 0b6ec9d..0000000 Binary files a/PSProxmox.zip and /dev/null differ diff --git a/Client/ProxmoxApiClient.cs b/PSProxmox/Client/ProxmoxApiClient.cs similarity index 100% rename from Client/ProxmoxApiClient.cs rename to PSProxmox/Client/ProxmoxApiClient.cs diff --git a/Cmdlets/ClearProxmoxIPPoolCmdlet.cs b/PSProxmox/Cmdlets/ClearProxmoxIPPoolCmdlet.cs similarity index 100% rename from Cmdlets/ClearProxmoxIPPoolCmdlet.cs rename to PSProxmox/Cmdlets/ClearProxmoxIPPoolCmdlet.cs diff --git a/Cmdlets/ConnectProxmoxServerCmdlet.cs b/PSProxmox/Cmdlets/ConnectProxmoxServerCmdlet.cs similarity index 100% rename from Cmdlets/ConnectProxmoxServerCmdlet.cs rename to PSProxmox/Cmdlets/ConnectProxmoxServerCmdlet.cs diff --git a/Cmdlets/DisconnectProxmoxServerCmdlet.cs b/PSProxmox/Cmdlets/DisconnectProxmoxServerCmdlet.cs similarity index 100% rename from Cmdlets/DisconnectProxmoxServerCmdlet.cs rename to PSProxmox/Cmdlets/DisconnectProxmoxServerCmdlet.cs diff --git a/Cmdlets/GetProxmoxClusterBackupCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxClusterBackupCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxClusterBackupCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxClusterBackupCmdlet.cs diff --git a/Cmdlets/GetProxmoxClusterCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxClusterCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxClusterCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxClusterCmdlet.cs diff --git a/Cmdlets/GetProxmoxIPPoolCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxIPPoolCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxIPPoolCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxIPPoolCmdlet.cs diff --git a/Cmdlets/GetProxmoxNetworkCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxNetworkCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxNetworkCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxNetworkCmdlet.cs diff --git a/Cmdlets/GetProxmoxNodeCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxNodeCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxNodeCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxNodeCmdlet.cs diff --git a/Cmdlets/GetProxmoxRoleCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxRoleCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxRoleCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxRoleCmdlet.cs diff --git a/Cmdlets/GetProxmoxSDNVnetCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxSDNVnetCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxSDNVnetCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxSDNVnetCmdlet.cs diff --git a/Cmdlets/GetProxmoxSDNZoneCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxSDNZoneCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxSDNZoneCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxSDNZoneCmdlet.cs diff --git a/Cmdlets/GetProxmoxStorageCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxStorageCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxStorageCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxStorageCmdlet.cs diff --git a/Cmdlets/GetProxmoxUserCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxUserCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxUserCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxUserCmdlet.cs diff --git a/Cmdlets/GetProxmoxVMCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxVMCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxVMCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxVMCmdlet.cs diff --git a/Cmdlets/GetProxmoxVMTemplateCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxVMTemplateCmdlet.cs similarity index 100% rename from Cmdlets/GetProxmoxVMTemplateCmdlet.cs rename to PSProxmox/Cmdlets/GetProxmoxVMTemplateCmdlet.cs diff --git a/Cmdlets/JoinProxmoxClusterCmdlet.cs b/PSProxmox/Cmdlets/JoinProxmoxClusterCmdlet.cs similarity index 100% rename from Cmdlets/JoinProxmoxClusterCmdlet.cs rename to PSProxmox/Cmdlets/JoinProxmoxClusterCmdlet.cs diff --git a/Cmdlets/LeaveProxmoxClusterCmdlet.cs b/PSProxmox/Cmdlets/LeaveProxmoxClusterCmdlet.cs similarity index 100% rename from Cmdlets/LeaveProxmoxClusterCmdlet.cs rename to PSProxmox/Cmdlets/LeaveProxmoxClusterCmdlet.cs diff --git a/Cmdlets/NewProxmoxClusterBackupCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxClusterBackupCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxClusterBackupCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxClusterBackupCmdlet.cs diff --git a/Cmdlets/NewProxmoxIPPoolCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxIPPoolCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxIPPoolCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxIPPoolCmdlet.cs diff --git a/Cmdlets/NewProxmoxNetworkCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxNetworkCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxNetworkCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxNetworkCmdlet.cs diff --git a/Cmdlets/NewProxmoxRoleCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxRoleCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxRoleCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxRoleCmdlet.cs diff --git a/Cmdlets/NewProxmoxSDNVnetCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxSDNVnetCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxSDNVnetCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxSDNVnetCmdlet.cs diff --git a/Cmdlets/NewProxmoxSDNZoneCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxSDNZoneCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxSDNZoneCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxSDNZoneCmdlet.cs diff --git a/Cmdlets/NewProxmoxStorageCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxStorageCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxStorageCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxStorageCmdlet.cs diff --git a/Cmdlets/NewProxmoxUserCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxUserCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxUserCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxUserCmdlet.cs diff --git a/Cmdlets/NewProxmoxVMBuilderCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxVMBuilderCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxVMBuilderCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxVMBuilderCmdlet.cs diff --git a/Cmdlets/NewProxmoxVMCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxVMCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxVMCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxVMCmdlet.cs diff --git a/Cmdlets/NewProxmoxVMFromTemplateCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxVMFromTemplateCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxVMFromTemplateCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxVMFromTemplateCmdlet.cs diff --git a/Cmdlets/NewProxmoxVMTemplateCmdlet.cs b/PSProxmox/Cmdlets/NewProxmoxVMTemplateCmdlet.cs similarity index 100% rename from Cmdlets/NewProxmoxVMTemplateCmdlet.cs rename to PSProxmox/Cmdlets/NewProxmoxVMTemplateCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxNetworkCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxNetworkCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxNetworkCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxNetworkCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxRoleCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxRoleCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxRoleCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxRoleCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxSDNVnetCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxSDNVnetCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxSDNVnetCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxSDNVnetCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxSDNZoneCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxSDNZoneCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxSDNZoneCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxSDNZoneCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxStorageCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxStorageCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxStorageCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxStorageCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxUserCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxUserCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxUserCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxUserCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxVMCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxVMCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxVMCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxVMCmdlet.cs diff --git a/Cmdlets/RemoveProxmoxVMTemplateCmdlet.cs b/PSProxmox/Cmdlets/RemoveProxmoxVMTemplateCmdlet.cs similarity index 100% rename from Cmdlets/RemoveProxmoxVMTemplateCmdlet.cs rename to PSProxmox/Cmdlets/RemoveProxmoxVMTemplateCmdlet.cs diff --git a/Cmdlets/RestartProxmoxVMCmdlet.cs b/PSProxmox/Cmdlets/RestartProxmoxVMCmdlet.cs similarity index 100% rename from Cmdlets/RestartProxmoxVMCmdlet.cs rename to PSProxmox/Cmdlets/RestartProxmoxVMCmdlet.cs diff --git a/Cmdlets/RestoreProxmoxClusterBackupCmdlet.cs b/PSProxmox/Cmdlets/RestoreProxmoxClusterBackupCmdlet.cs similarity index 100% rename from Cmdlets/RestoreProxmoxClusterBackupCmdlet.cs rename to PSProxmox/Cmdlets/RestoreProxmoxClusterBackupCmdlet.cs diff --git a/Cmdlets/StartProxmoxVMCmdlet.cs b/PSProxmox/Cmdlets/StartProxmoxVMCmdlet.cs similarity index 100% rename from Cmdlets/StartProxmoxVMCmdlet.cs rename to PSProxmox/Cmdlets/StartProxmoxVMCmdlet.cs diff --git a/Cmdlets/StopProxmoxVMCmdlet.cs b/PSProxmox/Cmdlets/StopProxmoxVMCmdlet.cs similarity index 100% rename from Cmdlets/StopProxmoxVMCmdlet.cs rename to PSProxmox/Cmdlets/StopProxmoxVMCmdlet.cs diff --git a/IPAM/IPAMManager.cs b/PSProxmox/IPAM/IPAMManager.cs similarity index 100% rename from IPAM/IPAMManager.cs rename to PSProxmox/IPAM/IPAMManager.cs diff --git a/Models/ProxmoxCluster.cs b/PSProxmox/Models/ProxmoxCluster.cs similarity index 100% rename from Models/ProxmoxCluster.cs rename to PSProxmox/Models/ProxmoxCluster.cs diff --git a/Models/ProxmoxClusterBackup.cs b/PSProxmox/Models/ProxmoxClusterBackup.cs similarity index 100% rename from Models/ProxmoxClusterBackup.cs rename to PSProxmox/Models/ProxmoxClusterBackup.cs diff --git a/Models/ProxmoxConnectionInfo.cs b/PSProxmox/Models/ProxmoxConnectionInfo.cs similarity index 100% rename from Models/ProxmoxConnectionInfo.cs rename to PSProxmox/Models/ProxmoxConnectionInfo.cs diff --git a/Models/ProxmoxIPPool.cs b/PSProxmox/Models/ProxmoxIPPool.cs similarity index 100% rename from Models/ProxmoxIPPool.cs rename to PSProxmox/Models/ProxmoxIPPool.cs diff --git a/Models/ProxmoxNetwork.cs b/PSProxmox/Models/ProxmoxNetwork.cs similarity index 100% rename from Models/ProxmoxNetwork.cs rename to PSProxmox/Models/ProxmoxNetwork.cs diff --git a/Models/ProxmoxNode.cs b/PSProxmox/Models/ProxmoxNode.cs similarity index 100% rename from Models/ProxmoxNode.cs rename to PSProxmox/Models/ProxmoxNode.cs diff --git a/Models/ProxmoxResponse.cs b/PSProxmox/Models/ProxmoxResponse.cs similarity index 100% rename from Models/ProxmoxResponse.cs rename to PSProxmox/Models/ProxmoxResponse.cs diff --git a/Models/ProxmoxRole.cs b/PSProxmox/Models/ProxmoxRole.cs similarity index 100% rename from Models/ProxmoxRole.cs rename to PSProxmox/Models/ProxmoxRole.cs diff --git a/Models/ProxmoxSDNVnet.cs b/PSProxmox/Models/ProxmoxSDNVnet.cs similarity index 100% rename from Models/ProxmoxSDNVnet.cs rename to PSProxmox/Models/ProxmoxSDNVnet.cs diff --git a/Models/ProxmoxSDNZone.cs b/PSProxmox/Models/ProxmoxSDNZone.cs similarity index 100% rename from Models/ProxmoxSDNZone.cs rename to PSProxmox/Models/ProxmoxSDNZone.cs diff --git a/Models/ProxmoxStorage.cs b/PSProxmox/Models/ProxmoxStorage.cs similarity index 100% rename from Models/ProxmoxStorage.cs rename to PSProxmox/Models/ProxmoxStorage.cs diff --git a/Models/ProxmoxTicket.cs b/PSProxmox/Models/ProxmoxTicket.cs similarity index 100% rename from Models/ProxmoxTicket.cs rename to PSProxmox/Models/ProxmoxTicket.cs diff --git a/Models/ProxmoxUser.cs b/PSProxmox/Models/ProxmoxUser.cs similarity index 100% rename from Models/ProxmoxUser.cs rename to PSProxmox/Models/ProxmoxUser.cs diff --git a/Models/ProxmoxVM.cs b/PSProxmox/Models/ProxmoxVM.cs similarity index 100% rename from Models/ProxmoxVM.cs rename to PSProxmox/Models/ProxmoxVM.cs diff --git a/Models/ProxmoxVMBuilder.cs b/PSProxmox/Models/ProxmoxVMBuilder.cs similarity index 100% rename from Models/ProxmoxVMBuilder.cs rename to PSProxmox/Models/ProxmoxVMBuilder.cs diff --git a/Models/ProxmoxVMTemplate.cs b/PSProxmox/Models/ProxmoxVMTemplate.cs similarity index 100% rename from Models/ProxmoxVMTemplate.cs rename to PSProxmox/Models/ProxmoxVMTemplate.cs diff --git a/PSProxmox.Main.csproj b/PSProxmox/PSProxmox.Main.csproj similarity index 95% rename from PSProxmox.Main.csproj rename to PSProxmox/PSProxmox.Main.csproj index 457542e..0cc1865 100644 --- a/PSProxmox.Main.csproj +++ b/PSProxmox/PSProxmox.Main.csproj @@ -92,7 +92,11 @@ - + + + + + diff --git a/PSProxmox.Main.sln b/PSProxmox/PSProxmox.Main.sln similarity index 100% rename from PSProxmox.Main.sln rename to PSProxmox/PSProxmox.Main.sln diff --git a/PSProxmox.csproj b/PSProxmox/PSProxmox.csproj similarity index 100% rename from PSProxmox.csproj rename to PSProxmox/PSProxmox.csproj diff --git a/Session/ProxmoxConnection.cs b/PSProxmox/Session/ProxmoxConnection.cs similarity index 100% rename from Session/ProxmoxConnection.cs rename to PSProxmox/Session/ProxmoxConnection.cs diff --git a/Session/ProxmoxSession.cs b/PSProxmox/Session/ProxmoxSession.cs similarity index 100% rename from Session/ProxmoxSession.cs rename to PSProxmox/Session/ProxmoxSession.cs diff --git a/Templates/TemplateManager.cs b/PSProxmox/Templates/TemplateManager.cs similarity index 100% rename from Templates/TemplateManager.cs rename to PSProxmox/Templates/TemplateManager.cs diff --git a/Utilities/JsonUtility.cs b/PSProxmox/Utilities/JsonUtility.cs similarity index 100% rename from Utilities/JsonUtility.cs rename to PSProxmox/Utilities/JsonUtility.cs diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..18cf184 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,47 @@ +# build.ps1 +# This script builds the PSProxmox module and creates a release package + +# Set the version based on the current date and time +$version = Get-Date -Format "yyyy.MM.dd.HHmm" +Write-Host "Building PSProxmox version $version" + +# Update the module version in the PSD1 file +$psd1Path = ".\Module\PSProxmox.psd1" +$psd1Content = Get-Content -Path $psd1Path -Raw +$psd1Content = $psd1Content -replace "ModuleVersion = '.*'", "ModuleVersion = '$version'" +Set-Content -Path $psd1Path -Value $psd1Content + +# Build the solution +Write-Host "Building solution..." +dotnet build .\PSProxmox\PSProxmox.Main.csproj -c Release + +# Create the release directory +$releaseDir = ".\Release\$version" +if (-not (Test-Path -Path $releaseDir)) { + New-Item -Path $releaseDir -ItemType Directory -Force | Out-Null + Write-Host "Created release directory: $releaseDir" +} + +# Copy the module files to the release directory +Copy-Item -Path .\Module\PSProxmox.psd1 -Destination $releaseDir -Force +Copy-Item -Path .\Module\bin\PSProxmox.dll -Destination $releaseDir -Force +Copy-Item -Path .\Module\LICENSE -Destination $releaseDir -Force +Copy-Item -Path .\Module\README.md -Destination $releaseDir -Force +Copy-Item -Path .\Module\Install-PSProxmox.ps1 -Destination $releaseDir -Force + +# Create a bin directory in the release directory +$releaseBinDir = "$releaseDir\bin" +if (-not (Test-Path -Path $releaseBinDir)) { + New-Item -Path $releaseBinDir -ItemType Directory -Force | Out-Null + Write-Host "Created bin directory: $releaseBinDir" +} + +# Copy the DLL to the bin directory +Copy-Item -Path .\Module\bin\PSProxmox.dll -Destination $releaseBinDir -Force + +# Create a ZIP file of the release +$zipPath = ".\Release\PSProxmox-$version.zip" +Compress-Archive -Path $releaseDir\* -DestinationPath $zipPath -Force +Write-Host "Created release package: $zipPath" + +Write-Host "Build completed successfully!"