Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Unable to parse time for NotBefore (on Linux) #3

Open
dmascord opened this issue Jul 5, 2019 · 5 comments
Open

Unable to parse time for NotBefore (on Linux) #3

dmascord opened this issue Jul 5, 2019 · 5 comments

Comments

@dmascord
Copy link

dmascord commented Jul 5, 2019

Hi,

I have installed your module, and have attempted to generate a PFX for Azure AD, but it returned an error as per below:

Cheers,

Damien


PS /home/tusker/dev> $password = ConvertTo-SecureString -Force -AsPlainText 'tusker'
PS /home/tusker/dev> $distinguishedName = @{
>> CommonName = 'tusker.onmicrosoft.com'
>> Country = 'AU'
>> StateOrProvince = 'NSW'
>> Locality = 'Sydney'
>> Organization = 'Tusker Technologies Pty Ltd'
>> OrganizationalUnit = 'PSE'
>> EmailAddress = '[email protected]'
>> }
PS /home/tusker/dev> $certificateParameters = $distinguishedName + @{
>>     OutCertPath = '/home/tusker/dev/tusker.pfx'
>> StartDate = [System.DateTimeOffset]::Now
>> Duration = [timespan]::FromDays(365)
>> Passphrase = $password
>> CertificateFormat = 'Pfx'
>> KeyLength = 4096
>> ForCertificateAuthority = $true
>> KeyUsage = 'DigitalSignature','KeyEncipherment'
>> EnhancedKeyUsage = 'ServerAuthentication','ClientAuthentication'
>> }
PS /home/tusker/dev> New-SelfSignedCertificate @certificateParameters -Force
New-SelfSignedCertificate : Cannot process argument transformation on parameter 'NotBefore'. Cannot convert the "7/5/19 7:13:14 PM +10:00" value of type "System.DateTimeOffset" to type "System.DateTime".
At line:1 char:27
+ New-SelfSignedCertificate @certificateParameters -Force
+                           ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [New-SelfSignedCertificate], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,New-SelfSignedCertificate
@rjmholt
Copy link
Contributor

rjmholt commented Jul 5, 2019

Looks like this is a result of #2. I imagine it requires converting using $datetime.UtcDateTime.

@rjmholt
Copy link
Contributor

rjmholt commented Aug 22, 2019

Just got a chance to look into this, but I'm having trouble reproducing the issue. Could you provide the full stack trace of the error?

@rjmholt
Copy link
Contributor

rjmholt commented Aug 22, 2019

Should be visible with $error[0] | fl * -force

@broo0ose
Copy link

broo0ose commented May 8, 2020

Hi,

I got the same error on a Raspberry Pi running Powershell.core running Linux,

Thanks

Exception             : System.Management.Automation.ParameterBindingArgumentTransformationException: Cannot process argument transformation on parameter 'NotBefore'. Cannot convert the "08/05/2020 13:56:00 +01:00" value of type "System.DateTimeOffset" to type "System.DateTime".
                         ---> System.Management.Automation.ArgumentTransformationMetadataException: Cannot convert the "08/05/2020 13:56:00 +01:00" value of type "System.DateTimeOffset" to type "System.DateTime".
                         ---> System.Management.Automation.PSInvalidCastException: Cannot convert the "08/05/2020 13:56:00 +01:00" value of type "System.DateTimeOffset" to type "System.DateTime".
                           at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4851
                           at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4245
                           at System.Management.Automation.LanguagePrimitives.ConversionData`1.Invoke(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4337
                           at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable backupTypeTable) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4790
                           at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, IFormatProvider formatProvider) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 1746
                           at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet) in /PowerShell/src/System.Management.Automation/engine/ArgumentTypeConverterAttribute.cs:line 142
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet) in /PowerShell/src/System.Management.Automation/engine/ArgumentTypeConverterAttribute.cs:line 165
                           at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags) in /PowerShell/src/System.Management.Automation/engine/ParameterBinderBase.cs:line 399
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags) in /PowerShell/src/System.Management.Automation/engine/ParameterBinderBase.cs:line 446
                           at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags) in /PowerShell/src/System.Management.Automation/engine/CmdletParameterBinderController.cs:line 1449
                           at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags) in /PowerShell/src/System.Management.Automation/engine/CmdletParameterBinderController.cs:line 1390
                           at System.Management.Automation.CmdletParameterBinderController.BindParameters(UInt32 parameterSets, Collection`1 arguments) in /PowerShell/src/System.Management.Automation/engine/CmdletParameterBinderController.cs:line 1168
                           at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments) in /PowerShell/src/System.Management.Automation/engine/CmdletParameterBinderController.cs:line 235
                           at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments) in /PowerShell/src/System.Management.Automation/engine/CmdletParameterBinderController.cs:line 108
                           at System.Management.Automation.CommandProcessor.BindCommandLineParameters() in /PowerShell/src/System.Management.Automation/engine/CommandProcessor.cs:line 178
                           at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues) in /PowerShell/src/System.Management.Automation/engine/CommandProcessor.cs:line 238
                           at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues) in /PowerShell/src/System.Management.Automation/engine/CommandProcessorBase.cs:line 440
                           at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream) in /PowerShell/src/System.Management.Automation/engine/pipeline.cs:line 1050
                           at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) in /PowerShell/src/System.Management.Automation/engine/pipeline.cs:line 498
                        --- End of stack trace from previous location ---
                           at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) in /PowerShell/src/System.Management.Automation/engine/pipeline.cs:line 584
                           at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) in /PowerShell/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs:line 493
                           at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame) in /PowerShell/src/System.Management.Automation/engine/interpreter/CallInstruction.Generated.cs:line 608
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) in /PowerShell/src/System.Management.Automation/engine/interpreter/ControlFlowInstructions.cs:line 357
TargetObject          : 
CategoryInfo          : InvalidData: (:) [New-SelfSignedCertificate], ParameterBindingArgumentTransformationException
FullyQualifiedErrorId : ParameterArgumentTransformationError,New-SelfSignedCertificate
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

@rjmholt
Copy link
Contributor

rjmholt commented May 12, 2020

@broo0ose could you share the original command invocation as well?

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

No branches or pull requests

3 participants