When using the 1.5.0 version of the code the new logic to check the bearer token expiry in Test-AccessToken is returning an error:
Test-AccessToken : Exception calling "Parse" with "3" argument(s): "String was not recognized as a valid DateTime." At C:\Users\<USERNAME>\Documents\WindowsPowerShell\Modules\IntuneWin32App\1.5.0\Private\Invoke-MSGraphOperation.ps1:110 char:19 if (-not (Test-AccessToken)) { ~~~~~~~~~~~~~~~~ CategoryInfo : NotSpecified: (:) [Test-AccessToken], MethodInvocationException FullyQualifiedErrorId : FormatException,Test-AccessToken
The line in question is:
$ExpiresOnUTC = [DateTimeOffset]::Parse($Global:AccessToken.ExpiresOn.ToString(), [System.Globalization.CultureInfo]::InvariantCulture, System.Globalization.DateTimeStyles]::AssumeUniversal).ToUniversalTime()
Seems to have an issue with the first arguement
Changing it to the below:
$ExpiresOnUTC = [DateTimeOffset]::Parse($Global:AccessToken.ExpiresOn.ToString()).ToUniversalTime()
Seems to fix the issue, but my knowledge is lacking to be able to tell if this is a good fix or a bodge fix.
Similar logic is found in the Invoke-AzureStorageBlobUpload function and possibly others. Has failed under PowerShell 5 on both Server 2016 and Windows 11 based machines running on UK time format.
When using the 1.5.0 version of the code the new logic to check the bearer token expiry in Test-AccessToken is returning an error:
Test-AccessToken : Exception calling "Parse" with "3" argument(s): "String was not recognized as a valid DateTime." At C:\Users\<USERNAME>\Documents\WindowsPowerShell\Modules\IntuneWin32App\1.5.0\Private\Invoke-MSGraphOperation.ps1:110 char:19 if (-not (Test-AccessToken)) { ~~~~~~~~~~~~~~~~ CategoryInfo : NotSpecified: (:) [Test-AccessToken], MethodInvocationException FullyQualifiedErrorId : FormatException,Test-AccessTokenThe line in question is:
$ExpiresOnUTC = [DateTimeOffset]::Parse($Global:AccessToken.ExpiresOn.ToString(), [System.Globalization.CultureInfo]::InvariantCulture, System.Globalization.DateTimeStyles]::AssumeUniversal).ToUniversalTime()Seems to have an issue with the first arguement
Changing it to the below:
$ExpiresOnUTC = [DateTimeOffset]::Parse($Global:AccessToken.ExpiresOn.ToString()).ToUniversalTime()Seems to fix the issue, but my knowledge is lacking to be able to tell if this is a good fix or a bodge fix.
Similar logic is found in the
Invoke-AzureStorageBlobUploadfunction and possibly others. Has failed under PowerShell 5 on both Server 2016 and Windows 11 based machines running on UK time format.