bc3dd6c535
Deploys a fully preconfigured OPNsense appliance into a Hyper-V lab in a single execution, re-running safely because every stage detects the current state before it acts. Main script: - Hyper-V platform detection and installation, exiting 3010 only when the hypervisor itself needs a restart - Random /20 block selection out of a private base network, divided into /24 networks whose VLAN tag is the third octet of their own network address - Zone based roles, with five server zones paired by index to five client zones, plus Management, Infrastructure, DMZ, Storage and Guest - Generated OPNsense config.xml delivered on a FAT32 VHDX at conf/config.xml - Generation 2 virtual machine with secure boot disabled and a LAN trunk carrying VLANs 1-4094 - Marker scoped teardown via RemoveExistingDeployment Toolkit functions: - Save-ToolkitModule, Install-HyperVPlatform, Test-PendingReboot - Expand-CompressedFile, Get-OPNSenseInstallationMedia - Get-HyperVStorageLocation, Get-HostUpstreamDNSConfiguration - New-RandomPassword, New-OPNSensePasswordHash - New-OPNSenseNetworkPlan, New-OPNSenseConfigurationDocument, Save-OPNSenseConfigurationDocument, New-OPNSenseConfigurationDisk - Initialize-OPNSenseVirtualSwitch, New-OPNSenseVirtualMachine, Remove-OPNSenseDeployment Configuration document covers interfaces, VLANs, Kea DHCPv4 scopes with PXE options, Unbound, outbound NAT, six firewall aliases and an ordered rule set that grants management full reach, allows the jump hosts over well known management ports, forces name resolution to approved resolvers, and pairs the client and server zones. Bundles 7-Zip, because the tar.exe included with Windows cannot read a raw bzip2 stream, and BCrypt.Net-Next for the appliance password hash. docs: Add readme with execution flow and generated per function reference docs: Add design specification under .ai/specification Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
47 lines
2.2 KiB
Markdown
47 lines
2.2 KiB
Markdown
# Save-ToolkitModule
|
|
|
|
[Function index](README.md) | [Repository readme](../README.md) | [Source](../Toolkit/Functions/Save-ToolkitModule.ps1)
|
|
|
|
> Idempotently saves one or more powershell modules into the toolkit module directory.
|
|
|
|
## Description
|
|
|
|
The module is only downloaded when it is not already present within the destination directory, or when the requested version is newer than the version that is already present.
|
|
This allows the parent script to be executed repeatedly without incurring repeated downloads.
|
|
|
|
## Parameters
|
|
|
|
| Name | Type | Required | Aliases | Description |
|
|
| --- | --- | --- | --- | --- |
|
|
| `Name` | `String[]` | Yes | N | One or more powershell module name(s) to save. |
|
|
| `Destination` | `IO.DirectoryInfo` | Yes | D, Path | A valid folder path. If the folder does not exist, it will be created. This is typically the "Toolkit\Modules" directory. |
|
|
| `RequiredVersion` | `String` | No | RV | An optional specific module version to save. When omitted, the latest available version will be saved. |
|
|
| `Repository` | `String` | No | R | The powershell repository to retrieve the module(s) from. |
|
|
| `Force` | `Switch` | No | F | Save the module(s) even if they are already present within the destination directory. |
|
|
| `ContinueOnError` | `Switch` | No | COE | Ignore failures. |
|
|
|
|
## Examples
|
|
|
|
### Example 1
|
|
|
|
```powershell
|
|
$SaveToolkitModuleParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary'
|
|
$SaveToolkitModuleParameters.Name = New-Object -TypeName 'System.Collections.Generic.List[System.String]'
|
|
$SaveToolkitModuleParameters.Name.Add('Indented.Net.IP')
|
|
$SaveToolkitModuleParameters.Name.Add('Indented.Net.Dns')
|
|
$SaveToolkitModuleParameters.Destination = $ModulesDirectory.FullName
|
|
$SaveToolkitModuleParameters.Verbose = $True
|
|
$SaveToolkitModuleResult = Save-ToolkitModule @SaveToolkitModuleParameters
|
|
|
|
Write-Output -InputObject ($SaveToolkitModuleResult)
|
|
```
|
|
|
|
## Notes
|
|
|
|
The saved module(s) are imported by the toolkit during the next execution of the parent script. Any module that is saved during the current execution is imported by this function so that it becomes immediately usable.
|
|
|
|
## Reference
|
|
|
|
- <https://learn.microsoft.com/en-us/powershell/module/powershellget/save-module>
|
|
|