diff --git a/Documentation/cmdlets/Get-ProxmoxIPPool.md b/Documentation/cmdlets/Get-ProxmoxIPPool.md new file mode 100644 index 0000000..2c45503 --- /dev/null +++ b/Documentation/cmdlets/Get-ProxmoxIPPool.md @@ -0,0 +1,108 @@ +# Get-ProxmoxIPPool + +Gets IP address pools. + +## Syntax + +```powershell +Get-ProxmoxIPPool + [-Name ] + [-UseRegex] + [] +``` + +## Description + +The `Get-ProxmoxIPPool` cmdlet retrieves IP address pools used with Proxmox VE virtual machines. You can retrieve all pools or a specific pool by name. + +## Parameters + +### -Name + +The name of the IP pool to retrieve. Supports wildcards and regex when used with -UseRegex. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + +### -UseRegex + +Use regular expressions for filtering. + +```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.ProxmoxIPPool + +## Notes + +- This cmdlet does not require a connection to a Proxmox VE server as IP pools are stored locally. +- If the `-Name` parameter is specified and the pool is not found, an error will be thrown. +- The `-Name` parameter supports wildcards (e.g., "Production*") by default. +- Use the `-UseRegex` parameter with `-Name` to filter using regular expressions (e.g., "^Prod[a-z]+$"). + +## Examples + +### Example 1: Get all IP pools + +```powershell +$pools = Get-ProxmoxIPPool +``` + +This example gets all IP pools. + +### Example 2: Get a specific IP pool by name + +```powershell +$pool = Get-ProxmoxIPPool -Name "Production" +``` + +This example gets the IP pool named "Production". + +### Example 3: Get IP pools by name using wildcards + +```powershell +$pools = Get-ProxmoxIPPool -Name "Prod*" +``` + +This example gets all IP pools with names starting with "Prod". + +### Example 4: Get IP pools by name using regex + +```powershell +$pools = Get-ProxmoxIPPool -Name "^Prod[a-z]+$" -UseRegex +``` + +This example gets all IP pools with names matching the pattern "Prod" followed by one or more lowercase letters. + +## Related Links + +- [New-ProxmoxIPPool](New-ProxmoxIPPool.md) +- [Clear-ProxmoxIPPool](Clear-ProxmoxIPPool.md) diff --git a/Documentation/cmdlets/Get-ProxmoxNode.md b/Documentation/cmdlets/Get-ProxmoxNode.md new file mode 100644 index 0000000..9cb2786 --- /dev/null +++ b/Documentation/cmdlets/Get-ProxmoxNode.md @@ -0,0 +1,159 @@ +# Get-ProxmoxNode + +Gets nodes from a Proxmox VE cluster. + +## Syntax + +```powershell +Get-ProxmoxNode + [-Connection ] + [-Name ] + [-UseRegex] + [-RawJson] + [] +``` + +## Description + +The `Get-ProxmoxNode` cmdlet retrieves nodes from a Proxmox VE cluster. You can retrieve all nodes or a specific node by name. + +## Parameters + +### -Connection + +The connection to the Proxmox VE server. + +```yaml +Type: ProxmoxConnection +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name + +The name of the node to retrieve. Supports wildcards and regex when used with -UseRegex. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + +### -UseRegex + +Use regular expressions for filtering. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +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.ProxmoxNode + +### System.String + +## Notes + +- This cmdlet requires a connection to a Proxmox VE server. Use `Connect-ProxmoxServer` to establish a connection. +- If no connection is specified, the cmdlet will use the default connection. +- If the `-RawJson` parameter is specified, the raw JSON response will be returned instead of parsed objects. +- If the `-Name` parameter is specified and the node is not found, an error will be thrown. +- The `-Name` parameter supports wildcards (e.g., "pve*") by default. +- Use the `-UseRegex` parameter with `-Name` to filter using regular expressions (e.g., "^pve[0-9]+$"). + +## Examples + +### Example 1: Get all nodes + +```powershell +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$nodes = Get-ProxmoxNode +``` + +This example gets all nodes from the Proxmox VE cluster. + +### Example 2: Get a specific node by name + +```powershell +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$node = Get-ProxmoxNode -Name "pve1" +``` + +This example gets the node named "pve1". + +### Example 3: Get nodes by name using wildcards + +```powershell +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$nodes = Get-ProxmoxNode -Name "pve*" +``` + +This example gets all nodes with names starting with "pve". + +### Example 4: Get nodes by name using regex + +```powershell +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$nodes = Get-ProxmoxNode -Name "^pve[0-9]+$" -UseRegex +``` + +This example gets all nodes with names matching the pattern "pve" followed by one or more digits. + +### Example 5: Get the raw JSON response + +```powershell +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$json = Get-ProxmoxNode -RawJson +``` + +This example gets the raw JSON response for all nodes. + +## Related Links + +- [Connect-ProxmoxServer](Connect-ProxmoxServer.md) +- [Get-ProxmoxVM](Get-ProxmoxVM.md) diff --git a/Documentation/cmdlets/Get-ProxmoxVM.md b/Documentation/cmdlets/Get-ProxmoxVM.md index 7990923..eacbbc5 100644 --- a/Documentation/cmdlets/Get-ProxmoxVM.md +++ b/Documentation/cmdlets/Get-ProxmoxVM.md @@ -6,9 +6,11 @@ Gets virtual machines from Proxmox VE. ```powershell Get-ProxmoxVM - -Connection + [-Connection ] [-Node ] [-VMID ] + [-Name ] + [-UseRegex] [-RawJson] [] ``` @@ -28,7 +30,7 @@ Type: ProxmoxConnection Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 0 Default value: None Accept pipeline input: False @@ -67,6 +69,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Name + +The name of the virtual machine to retrieve. Supports wildcards and regex when used with -UseRegex. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + +### -UseRegex + +Use regular expressions for filtering. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -RawJson Whether to return the raw JSON response instead of parsed objects. @@ -100,16 +134,19 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## Notes - This cmdlet requires a connection to a Proxmox VE server. Use `Connect-ProxmoxServer` to establish a connection. +- If no connection is specified, the cmdlet will use the default 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. +- The `-Name` parameter supports wildcards (e.g., "web*") by default. +- Use the `-UseRegex` parameter with `-Name` to filter using regular expressions (e.g., "^web[0-9]+$"). ## Examples ### Example 1: Get all VMs ```powershell -$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) -$vms = Get-ProxmoxVM -Connection $connection +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$vms = Get-ProxmoxVM ``` This example gets all VMs from all nodes. @@ -117,8 +154,8 @@ 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" +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$vms = Get-ProxmoxVM -Node "pve1" ``` This example gets all VMs on the node "pve1". @@ -126,17 +163,35 @@ 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 +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$vm = Get-ProxmoxVM -VMID 100 ``` This example gets the VM with ID 100. -### Example 4: Get the raw JSON response +### Example 4: Get VMs by name using wildcards ```powershell -$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) -$json = Get-ProxmoxVM -Connection $connection -RawJson +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$vms = Get-ProxmoxVM -Name "web*" +``` + +This example gets all VMs with names starting with "web". + +### Example 5: Get VMs by name using regex + +```powershell +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$vms = Get-ProxmoxVM -Name "^web[0-9]+$" -UseRegex +``` + +This example gets all VMs with names matching the pattern "web" followed by one or more digits. + +### Example 6: Get the raw JSON response + +```powershell +Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential) +$json = Get-ProxmoxVM -RawJson ``` This example gets the raw JSON response for all VMs. diff --git a/Documentation/cmdlets/Get-ProxmoxVMTemplate.md b/Documentation/cmdlets/Get-ProxmoxVMTemplate.md new file mode 100644 index 0000000..17c1c37 --- /dev/null +++ b/Documentation/cmdlets/Get-ProxmoxVMTemplate.md @@ -0,0 +1,109 @@ +# Get-ProxmoxVMTemplate + +Gets virtual machine templates. + +## Syntax + +```powershell +Get-ProxmoxVMTemplate + [-Name ] + [-UseRegex] + [] +``` + +## Description + +The `Get-ProxmoxVMTemplate` cmdlet retrieves virtual machine templates. You can retrieve all templates or a specific template by name. + +## Parameters + +### -Name + +The name of the template to retrieve. Supports wildcards and regex when used with -UseRegex. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + +### -UseRegex + +Use regular expressions for filtering. + +```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.ProxmoxVMTemplate + +## Notes + +- This cmdlet does not require a connection to a Proxmox VE server as templates are stored locally. +- If the `-Name` parameter is specified and the template is not found, an error will be thrown. +- The `-Name` parameter supports wildcards (e.g., "Ubuntu*") by default. +- Use the `-UseRegex` parameter with `-Name` to filter using regular expressions (e.g., "^Ubuntu-[0-9]+\\.[0-9]+$"). + +## Examples + +### Example 1: Get all templates + +```powershell +$templates = Get-ProxmoxVMTemplate +``` + +This example gets all templates. + +### Example 2: Get a specific template by name + +```powershell +$template = Get-ProxmoxVMTemplate -Name "Ubuntu-Template" +``` + +This example gets the template named "Ubuntu-Template". + +### Example 3: Get templates by name using wildcards + +```powershell +$templates = Get-ProxmoxVMTemplate -Name "Ubuntu*" +``` + +This example gets all templates with names starting with "Ubuntu". + +### Example 4: Get templates by name using regex + +```powershell +$templates = Get-ProxmoxVMTemplate -Name "^Ubuntu-[0-9]+\\.[0-9]+$" -UseRegex +``` + +This example gets all templates with names matching the pattern "Ubuntu-" followed by a version number (e.g., "Ubuntu-20.04"). + +## Related Links + +- [New-ProxmoxVMTemplate](New-ProxmoxVMTemplate.md) +- [Remove-ProxmoxVMTemplate](Remove-ProxmoxVMTemplate.md) +- [New-ProxmoxVMFromTemplate](New-ProxmoxVMFromTemplate.md) diff --git a/PSProxmox/Cmdlets/FilteringCmdlet.cs b/PSProxmox/Cmdlets/FilteringCmdlet.cs new file mode 100644 index 0000000..7d40c4b --- /dev/null +++ b/PSProxmox/Cmdlets/FilteringCmdlet.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Management.Automation; +using System.Text.RegularExpressions; + +namespace PSProxmox.Cmdlets +{ + /// + /// Base class for cmdlets that support filtering with wildcards and regex. + /// + public abstract class FilteringCmdlet : ProxmoxCmdlet + { + /// + /// Use regular expressions for filtering. + /// + [Parameter(Mandatory = false)] + public SwitchParameter UseRegex { get; set; } + + /// + /// Filters a collection of objects by a property value using wildcards or regex. + /// + /// The type of objects to filter. + /// The collection of objects to filter. + /// The name of the property to filter by. + /// The pattern to match. Can be a wildcard or regex pattern. + /// A filtered collection of objects. + protected IEnumerable FilterByProperty(IEnumerable items, string propertyName, string pattern) + { + if (string.IsNullOrEmpty(pattern)) + { + return items; + } + + var filteredItems = new List(); + var type = typeof(T); + var property = type.GetProperty(propertyName); + + if (property == null) + { + throw new ArgumentException($"Property '{propertyName}' not found on type '{type.Name}'."); + } + + foreach (var item in items) + { + var value = property.GetValue(item)?.ToString(); + if (value == null) + { + continue; + } + + bool isMatch; + if (UseRegex.IsPresent) + { + // Use regex matching + try + { + isMatch = Regex.IsMatch(value, pattern, RegexOptions.IgnoreCase); + } + catch (ArgumentException ex) + { + throw new ArgumentException($"Invalid regular expression pattern: {ex.Message}", ex); + } + } + else + { + // Use wildcard matching + isMatch = WildcardMatch(value, pattern); + } + + if (isMatch) + { + filteredItems.Add(item); + } + } + + return filteredItems; + } + + /// + /// Matches a string against a wildcard pattern. + /// + /// The input string to match. + /// The wildcard pattern to match against. + /// True if the input matches the pattern, false otherwise. + private bool WildcardMatch(string input, string pattern) + { + // Convert wildcard pattern to regex pattern + string regexPattern = "^" + Regex.Escape(pattern) + .Replace("\\*", ".*") + .Replace("\\?", ".") + "$"; + + return Regex.IsMatch(input, regexPattern, RegexOptions.IgnoreCase); + } + } +} diff --git a/PSProxmox/Cmdlets/GetProxmoxIPPoolCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxIPPoolCmdlet.cs index 76b1ec9..2cc50f7 100644 --- a/PSProxmox/Cmdlets/GetProxmoxIPPoolCmdlet.cs +++ b/PSProxmox/Cmdlets/GetProxmoxIPPoolCmdlet.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Management.Automation; using PSProxmox.IPAM; using PSProxmox.Models; @@ -20,12 +21,12 @@ namespace PSProxmox.Cmdlets /// [Cmdlet(VerbsCommon.Get, "ProxmoxIPPool")] [OutputType(typeof(ProxmoxIPPool))] - public class GetProxmoxIPPoolCmdlet : PSCmdlet + public class GetProxmoxIPPoolCmdlet : FilteringCmdlet { private static readonly IPAMManager _ipamManager = new IPAMManager(); /// - /// The name of the IP pool to retrieve. + /// The name of the IP pool to retrieve. Supports wildcards and regex when used with -UseRegex. /// [Parameter(Mandatory = false, Position = 0)] public string Name { get; set; } @@ -37,7 +38,7 @@ namespace PSProxmox.Cmdlets { try { - if (string.IsNullOrEmpty(Name)) + if (string.IsNullOrEmpty(Name) || UseRegex.IsPresent || Name.Contains("*") || Name.Contains("?")) { // Get all pools var pools = new List(); @@ -45,6 +46,13 @@ namespace PSProxmox.Cmdlets { pools.Add(ProxmoxIPPool.FromIPPool(pool)); } + + // Apply name filtering if specified + if (!string.IsNullOrEmpty(Name)) + { + pools = FilterByProperty(pools, "Name", Name).ToList(); + } + WriteObject(pools, true); } else diff --git a/PSProxmox/Cmdlets/GetProxmoxNodeCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxNodeCmdlet.cs index 1036ba7..885a147 100644 --- a/PSProxmox/Cmdlets/GetProxmoxNodeCmdlet.cs +++ b/PSProxmox/Cmdlets/GetProxmoxNodeCmdlet.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Management.Automation; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -24,7 +25,7 @@ namespace PSProxmox.Cmdlets /// [Cmdlet(VerbsCommon.Get, "ProxmoxNode")] [OutputType(typeof(ProxmoxNode), typeof(string))] - public class GetProxmoxNodeCmdlet : PSCmdlet + public class GetProxmoxNodeCmdlet : FilteringCmdlet { /// /// The connection to the Proxmox VE server. @@ -33,7 +34,7 @@ namespace PSProxmox.Cmdlets public ProxmoxConnection Connection { get; set; } /// - /// The name of the node to retrieve. + /// The name of the node to retrieve. Supports wildcards and regex when used with -UseRegex. /// [Parameter(Mandatory = false)] public string Name { get; set; } @@ -54,7 +55,7 @@ namespace PSProxmox.Cmdlets var client = new ProxmoxApiClient(Connection, this); string response; - if (string.IsNullOrEmpty(Name)) + if (string.IsNullOrEmpty(Name) || UseRegex.IsPresent || Name.Contains("*") || Name.Contains("?")) { // Get all nodes response = client.Get("nodes"); @@ -67,6 +68,12 @@ namespace PSProxmox.Cmdlets nodes.Add(node); } + // Apply name filtering if specified + if (!string.IsNullOrEmpty(Name)) + { + nodes = FilterByProperty(nodes, "Name", Name).ToList(); + } + if (RawJson.IsPresent) { WriteObject(response); diff --git a/PSProxmox/Cmdlets/GetProxmoxVMCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxVMCmdlet.cs index a7e6b31..32cf8ae 100644 --- a/PSProxmox/Cmdlets/GetProxmoxVMCmdlet.cs +++ b/PSProxmox/Cmdlets/GetProxmoxVMCmdlet.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Management.Automation; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -28,7 +29,7 @@ namespace PSProxmox.Cmdlets /// [Cmdlet(VerbsCommon.Get, "ProxmoxVM")] [OutputType(typeof(ProxmoxVM), typeof(string))] - public class GetProxmoxVMCmdlet : ProxmoxCmdlet + public class GetProxmoxVMCmdlet : FilteringCmdlet { /// @@ -43,6 +44,12 @@ namespace PSProxmox.Cmdlets [Parameter(Mandatory = false)] public string Node { get; set; } + /// + /// The name of the virtual machine to retrieve. Supports wildcards and regex when used with -UseRegex. + /// + [Parameter(Mandatory = false, Position = 2)] + public string Name { get; set; } + /// /// Whether to return the raw JSON response. /// @@ -154,6 +161,12 @@ namespace PSProxmox.Cmdlets } } + // Apply name filtering if specified + if (!string.IsNullOrEmpty(Name)) + { + allVMs = FilterByProperty(allVMs, "Name", Name).ToList(); + } + if (RawJson.IsPresent) { WriteObject(JsonConvert.SerializeObject(allVMs)); @@ -177,6 +190,12 @@ namespace PSProxmox.Cmdlets nodeVMs.Add(vm); } + // Apply name filtering if specified + if (!string.IsNullOrEmpty(Name)) + { + nodeVMs = FilterByProperty(nodeVMs, "Name", Name).ToList(); + } + if (RawJson.IsPresent) { WriteObject(response); diff --git a/PSProxmox/Cmdlets/GetProxmoxVMTemplateCmdlet.cs b/PSProxmox/Cmdlets/GetProxmoxVMTemplateCmdlet.cs index 8c8fbfa..6e27522 100644 --- a/PSProxmox/Cmdlets/GetProxmoxVMTemplateCmdlet.cs +++ b/PSProxmox/Cmdlets/GetProxmoxVMTemplateCmdlet.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Management.Automation; using PSProxmox.Models; using PSProxmox.Templates; @@ -20,10 +21,10 @@ namespace PSProxmox.Cmdlets /// [Cmdlet(VerbsCommon.Get, "ProxmoxVMTemplate")] [OutputType(typeof(ProxmoxVMTemplate))] - public class GetProxmoxVMTemplateCmdlet : PSCmdlet + public class GetProxmoxVMTemplateCmdlet : FilteringCmdlet { /// - /// The name of the template to retrieve. + /// The name of the template to retrieve. Supports wildcards and regex when used with -UseRegex. /// [Parameter(Mandatory = false, Position = 0)] public string Name { get; set; } @@ -35,7 +36,7 @@ namespace PSProxmox.Cmdlets { try { - if (string.IsNullOrEmpty(Name)) + if (string.IsNullOrEmpty(Name) || UseRegex.IsPresent || Name.Contains("*") || Name.Contains("?")) { // Get all templates var templates = new List(); @@ -43,6 +44,13 @@ namespace PSProxmox.Cmdlets { templates.Add(template); } + + // Apply name filtering if specified + if (!string.IsNullOrEmpty(Name)) + { + templates = FilterByProperty(templates, "Name", Name).ToList(); + } + WriteObject(templates, true); } else