Dot-source the engine before calling its functions:
. .\WinPECredentialTransfer.ps1All entry scripts dot-source WinPECredentialTransfer.ps1. Keep the shared
engine in the same directory as the selected wrapper.
Recommended WinPE interface. It verifies the WinPE environment, prompts for each
requested credential, mounts the offline SOFTWARE hive with a unique name,
calls New-WPCTCredentialTransfer, and unloads the hive in finally.
Use -SecretIds to define the credential prompts. Use
-SkipEnvironmentCheck only for controlled testing outside WinPE.
Parameters:
WindowsPath- installed Windows directory.SecretFilePath- destination.binpath.RegistrySubKey- bootstrap key relative to the offlineSOFTWAREhive.SecretIds- IDs for credentials that the wrapper prompts to collect.RequiredSecretIds- IDs that must exist in the payload.Metadata- optional serializable deployment metadata.AllowOverwrite- explicitly replace existing engine-owned artifacts.SkipEnvironmentCheck- bypass WinPE detection for controlled testing.
Recommended full-Windows interface. It rejects WinPE, calls
Invoke-WPCTCredentialImport, and reports the DPAPI identity, transfer ID,
created CLIXML files, and cleanup state.
Parameters:
SecretFilePath- encrypted.bintransfer path.OutputDirectory- destination for DPAPI-protected CLIXML.RegistrySubKey- bootstrap key belowHKLM:\SOFTWARE.RequiredSecretIds- IDs required by the consumer.KeepTransfer- retain the package and registry data after import.AllowClixmlOverwrite- explicitly replace existing credential XML files.SkipEnvironmentCheck- bypass full-Windows detection for controlled tests.
Mounts an installed Windows SOFTWARE hive beneath HKLM.
Parameters:
WindowsPath- installed Windows directory, such asC:\Windows.MountName- temporaryHKLMmount name. Default:WPCTOffline.
The success payload contains MountName, RegistryRoot, and HivePath.
Always dismount the hive in a finally block.
Unloads a hive previously mounted by Mount-WPCTOfflineSoftwareHive.
Parameters:
MountName- mount name used during loading.
Creates the encrypted .bin package and protected registry bootstrap key.
Parameters:
Secrets- one or more credential descriptors.SecretFilePath- exact destination path for the binary package.OfflineRegistryRoot- mounted offline hive root, such asHKLM:\WPCTOffline.RegistrySubKey- subkey relative to the supplied registry root. Rooted provider paths, traversal segments, wildcards, and empty segments are rejected.Metadata- optional serializable caller data.RequiredSecretIds- IDs that must exist in the payload.MachineIdentity- optional identity override, primarily for testing.AllowOverwrite- explicitly replace an existing package and an existing engine-owned bootstrap key. The existing transfer ID, registry schema, and engine version must all be valid before the key can be replaced. The previous package and registry key remain as protected transaction backups until the replacement commits. Registry backups and final keys are copied into freshly ACL-protected keys; secret-bearing keys are not renamed.MaximumPackageBytes- package-size ceiling. Default: 10 MB.
Preferred secret input:
[pscustomobject]@{
Id = 'DeploymentShare'
Credential = Get-Credential
}The success payload includes the engine version, transfer ID, package path,
registry path, binding fields, binding mode, secret count, Committed, and
CleanupComplete. A committed replacement with retained artifacts returns
Success = false and the exact recovery paths.
Reads, authenticates, decrypts, and validates an existing transfer.
Parameters:
SecretFilePath- path to the encrypted package.RegistrySubKey- safe relative bootstrap key belowHKLM:\SOFTWARE.RequiredSecretIds- credential IDs required by the consumer.MachineIdentity- optional identity override for testing.MaximumPackageBytes- maximum package size accepted. Default: 10 MB.
This function does not export CLIXML or remove the transfer. It rejects registry data unless the transfer ID, registry schema, and engine version form a complete ownership marker.
Exports every credential in a validated payload as DPAPI-protected CLIXML.
Parameters:
Payload- successful payload fromRead-WPCTCredentialTransfer.OutputDirectory- destination directory.AllowOverwrite- transactionally replace existing credential files.
Each filename is <SecretId>.xml. Files can normally be decrypted only by the
same account on the same Windows installation. Export occurs in a protected
staging directory and is rolled back if staging or commit fails. Staging,
backup, and destination directories all receive the credential-directory ACL.
Paths containing filesystem reparse points are rejected. If rollback cannot
restore every previous file, RolledBack is false and the protected
BackupDirectory is retained for manual recovery. Success is returned only
after staging and backup directories are removed and verified absent.
Removes the encrypted package, its temporary-file variant, and the bootstrap registry key.
Parameters:
SecretFilePath- package path.RegistrySubKey- safe relative bootstrap key belowHKLM:\SOFTWARE.TransferId- required authenticated ownership ID. Missing or mismatched ownership prevents cleanup.MaximumPackageBytes- maximum package size accepted during ownership authentication. Default: 10 MB.
Cleanup refuses to delete any artifact unless both the registry ownership marker and encrypted package authenticate to the supplied transfer ID. The temporary file and package must be removed successfully before the registry secret is deleted. The result reports each artifact separately.
Recommended full-Windows entry point. It reads the transfer, exports CLIXML, and cleans up.
Parameters:
SecretFilePath- encrypted.binpackage path.OutputDirectory- CLIXML destination.RegistrySubKey- bootstrap registry subkey.RequiredSecretIds- IDs required by the consumer.KeepTransfer- retain the package and registry key after successful export.AllowClixmlOverwrite- allow transactional replacement of existing CLIXML.MaximumPackageBytes- maximum package size accepted. Default: 10 MB.
The success payload contains ClixmlFiles, CreatedFor, and CleanedUp.
These functions are public because the engine is dot-sourced, but callers normally do not need them directly:
New-WPCTResultResolve-WPCTRegistrySubKeyAssert-WPCTPathHasNoReparsePointRead-WPCTBoundedFileClear-WPCTByteArrayTest-WPCTRegistryTransferMarkerNew-WPCTRandomBytesTest-WPCTFixedTimeEqualsConvertTo-WPCTNormalizedHardwareValueGet-WPCTMachineIdentityGet-WPCTBindingContextBytesInvoke-WPCTHmacSha256Invoke-WPCTHkdfSha256New-WPCTDerivedKeysProtect-WPCTBytesUnprotect-WPCTBytesConvertTo-WPCTSerializableSecretsTest-WPCTPayloadSet-WPCTRegistryKeyAclNew-WPCTRegistryTransferKeyGet-WPCTRegistryTransferKeyDataCopy-WPCTRegistryTransferKeySet-WPCTFileAclSet-WPCTCredentialDirectoryAclTest-WPCTRegistryOwnership
The default registry subkey is:
WinPECredentialTransfer\Bootstrap
Values written beneath it:
| Name | Type | Meaning |
|---|---|---|
RandomSecret |
Binary | 32-byte bootstrap secret |
BindingFields |
MultiString | Hardware fields selected in WinPE |
SchemaVersion |
DWord | Registry schema version |
TransferId |
String | Unique cleanup and package ownership marker |
EngineVersion |
String | Engine version that created the transfer |
Engine version 3.0 writes binary package version 3, registry schema 4, and payload schema 4.