diff --git a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psd1 b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psd1 index cccdf07..e8a44fc 100644 --- a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psd1 +++ b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psd1 @@ -24,7 +24,7 @@ RootModule = 'Microsoft.Xrm.Data.Powershell.psm1' # Version number of this module. -ModuleVersion = '2.8.10' +ModuleVersion = '2.8.11' # ID used to uniquely identify this module GUID = '7df9c140-65c3-4862-b3bc-73fad633aae4' diff --git a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 index 9f37b83..99933e8 100644 --- a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 +++ b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 @@ -125,6 +125,7 @@ function Connect-CrmOnline{ if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent -eq $true) { Enable-CrmConnectorVerboseLogging } + if(-not [string]::IsNullOrEmpty($ServerUrl) -and $ServerUrl.StartsWith("https://","CurrentCultureIgnoreCase") -ne $true){ Write-Verbose "ServerUrl is missing https, fixing URL: https://$ServerUrl" $ServerUrl = "https://" + $ServerUrl @@ -136,7 +137,7 @@ function Connect-CrmOnline{ if($BypassTokenCache){ $cs += ";TokenCacheStorePath=" } - + if($ForceDiscovery){ #SkipDiscovery is true by default and generally not necessary Write-Verbose "ForceDiscovery: SkipDiscovery=False" @@ -151,6 +152,13 @@ function Connect-CrmOnline{ } } + if($ConnectionTimeoutInSeconds -and $ConnectionTimeoutInSeconds -gt 0){ + $newTimeout = New-Object System.TimeSpan -ArgumentList 0,0,$ConnectionTimeoutInSeconds + Write-Verbose "Setting new connection timeout of $newTimeout" + #set the timeout on the MaxConnectionTimeout static + [Microsoft.Xrm.Tooling.Connector.CrmServiceClient]::MaxConnectionTimeout = $newTimeout + } + if($ConnectionString){ if(!$ConnectionString -or $ConnectionString.Length -eq 0){ throw "Cannot create the CrmServiceClient, the connection string is null" @@ -189,7 +197,7 @@ function Connect-CrmOnline{ } } else{ - if(-not [string]::IsNullOrEmpty($Username)){ + if(-not [string]::IsNullOrEmpty($Username) -and $ForceOAuth -eq $false){ $cs += ";Username=$UserName" Write-Warning "UserName parameter is only compatible with oAuth, forcing auth mode to oAuth" $ForceOAuth = $true