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.AuthType); $instanceConnectionString = $instanceConnectionString.Replace("[Url]", $InputObject.Url); $instanceConnectionString = $instanceConnectionString.Replace("[Username]", $Global:CdsContext.UserName); $instanceConnectionString = $instanceConnectionString.Replace("[Password]", $Global:CdsContext.UserPassword); $instanceConnectionString += $Global:CdsContext.ConnectionStringParameters; $instanceConnectionString; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Out-CdsConnectionString -Alias *; |