Functions/Connection/Out-CdsConnectionString.ps1
<#
.SYNOPSIS Build Connection String from connection. #> function Out-CdsConnectionString { [CmdletBinding()] [OutputType([String])] param ( [Parameter(Mandatory, ValueFromPipeline)] $InputObject ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $connectionStringTemplate = "AuthType=[AuthType];Url=[Url];Username=[Username];Password=[Password];"; $instanceConnectionString = $connectionStringTemplate; $instanceConnectionString = $instanceConnectionString.Replace("[AuthType]", $Global:CdsContext.CurrentConnection.AuthType); $instanceConnectionString = $instanceConnectionString.Replace("[Url]", $InputObject.CurrentConnection.Url); $instanceConnectionString = $instanceConnectionString.Replace("[Username]", $Global:CdsContext.CurrentConnection.UserName); $instanceConnectionString = $instanceConnectionString.Replace("[Password]", $Global:CdsContext.CurrentConnection.UserPassword); $instanceConnectionString += $Global:CdsContext.CurrentConnection.ConnectionStringParameters; $instanceConnectionString; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Out-CdsConnectionString -Alias *; |