Functions/Connection/Out-CdsConnectionString.ps1
<#
.SYNOPSIS Build Connection String from connection. #> function Out-CdsConnectionString { [CmdletBinding()] [OutputType([String])] param ( [Parameter(Mandatory = $true, ValueFromPipeline)] $CdsInstance ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { # TODO : Handle different auth type connection string formats # => https://docs.microsoft.com/fr-fr/powerapps/developer/common-data-service/xrm-tooling/use-connection-strings-xrm-tooling-connect $connectionStringTemplate = "AuthType=[AuthType];Url=[Url];Username=[Username];Password=[Password];"; $instanceConnectionString = $connectionStringTemplate; $instanceConnectionString = $instanceConnectionString.Replace("[AuthType]", $CdsInstance.ParentConnection.AuthType); $instanceConnectionString = $instanceConnectionString.Replace("[Url]", $CdsInstance.Url); $instanceConnectionString = $instanceConnectionString.Replace("[Username]", $CdsInstance.ParentConnection.UserName); $instanceConnectionString = $instanceConnectionString.Replace("[Password]", $CdsInstance.ParentConnection.UserPassword); $instanceConnectionString += $CdsInstance.ParentConnection.ConnectionStringParameters; $instanceConnectionString; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Out-CdsConnectionString -Alias *; |