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>
3.2 KiB
3.2 KiB
Expand-CompressedFile
Function index | Repository readme | Source
Expands a compressed file or archive using the first available extraction provider.
Description
The extraction provider is selected based upon the archive format and the tooling that is available on the device.
- 7-Zip - "Toolkit\Tools<Architecture>\7z.exe" is preferred, followed by any copy of "7z.exe" or "7za.exe" that is available within the process path, followed by the installed copy within the program files directory. This provider handles every supported format, including a raw bzip2 stream such as an OPNsense disc image.
- BSDTar - "tar.exe" is included with the operating system, but it can only read genuine tar archives. It is the only provider that natively supports the removal of leading path components.
- .NET - The "System.IO.Compression" namespace is used for zip archives and raw gzip streams.
Extraction always occurs within a staging directory so that the leading path component removal and the inclusion filter can be applied before anything is placed into the destination directory.
Parameters
| Name | Type | Required | Aliases | Description |
|---|---|---|---|---|
Path |
IO.FileInfo |
Yes | P | A valid file path to the compressed file or archive that will be expanded. |
Destination |
IO.DirectoryInfo |
Yes | D | A valid folder path. If the folder does not exist, it will be created. |
StripComponents |
Int32 |
No | SC | The number of leading path components to remove from each extracted item. This is the equivalent of the tar "--strip-components" argument and allows a single nested item, such as a disc image, to be placed directly within the destination directory. |
IncludeFilter |
String[] |
No | IF | One or more wildcard expressions. Only the extracted items whose name matches one of the expressions will be placed into the destination directory. |
Force |
Switch |
No | F | Overwrite any item that already exists within the destination directory. |
ContinueOnError |
Switch |
No | COE | Ignore failures. |
Examples
Example 1
$ExpandCompressedFileParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary'
$ExpandCompressedFileParameters.Path = "$($ContentDirectory.FullName)\ISOs\OPNsense-26.1.6-dvd-amd64.iso.bz2"
$ExpandCompressedFileParameters.Destination = "$($ContentDirectory.FullName)\ISOs"
$ExpandCompressedFileParameters.StripComponents = 1
$ExpandCompressedFileParameters.IncludeFilter = New-Object -TypeName 'System.Collections.Generic.List[System.String]'
$ExpandCompressedFileParameters.IncludeFilter.Add('*.iso')
$ExpandCompressedFileParameters.Verbose = $True
$ExpandCompressedFileResult = Expand-CompressedFile @ExpandCompressedFileParameters
Write-Output -InputObject ($ExpandCompressedFileResult.ItemList)
Notes
The copy of "tar.exe" that is included with the operating system cannot read a raw, non-tar bzip2 stream. It fails with "Unrecognized archive format", which is the reason that 7-Zip is bundled within the toolkit.