Skip to content

VaultParameters of Type TimeSpan are Converted to HashTable #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
marshallwp opened this issue Mar 26, 2025 · 0 comments
Open
3 tasks done

VaultParameters of Type TimeSpan are Converted to HashTable #239

marshallwp opened this issue Mar 26, 2025 · 0 comments

Comments

@marshallwp
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

I've written an extension for PowerShell/SecretManagement that allows users to set an optional VaultParameter during registration called ResyncCacheIfOlderThan. This value is of data type TimeSpan. Recently it has come to my attention that when users supply a VaultParameters hashtable containing this property during vault registration, the TimeSpan is converted to a HashTable. Sadly said Hashtable has no implicit conversion back to TimeSpan, so any functions expecting the latter will fail.

Expected behavior

PS> $VaultParameters = @{
	ResyncCacheIfOlderThan = New-TimeSpan -Hours 2
}
PS> Register-SecretVault -Name "warden2" -ModuleName SecretManagement.Warden -VaultParameters $VaultParameters
PS> (Get-SecretVault -Name warden2).VaultParameters.ResyncCacheIfOlderThan | gm

   TypeName: System.TimeSpan

Actual behavior

PS> $VaultParameters = @{
	ResyncCacheIfOlderThan = New-TimeSpan -Hours 2
}
PS> Register-SecretVault -Name "warden2" -ModuleName SecretManagement.Warden -VaultParameters $VaultParameters
PS> (Get-SecretVault -Name warden2).VaultParameters.ResyncCacheIfOlderThan | gm

   TypeName: System.Collections.Hashtable

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.7
PSEdition                      Core
GitCommitId                    7.4.7
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

N/A

Visuals

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant