Private/ConvertTo-RaidinessGraphClientTimeout.ps1
|
function ConvertTo-RaidinessGraphClientTimeout { [CmdletBinding()] param( [Parameter(Mandatory)] [object] $Value, [Parameter(Mandatory)] [type] $ParameterType ) if ($ParameterType -eq [System.TimeSpan]) { if ($Value -is [System.TimeSpan]) { return $Value } return [System.TimeSpan]::FromSeconds([double]$Value) } # Some Graph SDK versions expose ClientTimeout as Int32 even though the # corresponding request-context property is a TimeSpan. Retain the full # configured duration when conversion to whole seconds is required. $convertedValue = $Value if ($Value -is [System.TimeSpan]) { $convertedValue = [Math]::Ceiling($Value.TotalSeconds) } [System.Management.Automation.LanguagePrimitives]::ConvertTo($convertedValue, $ParameterType) } |