Functions/Write-DbDeployParameterLog.ps1

<#
.SYNOPSIS
    Logs database deployment parameters to the console.
 
.DESCRIPTION
    The Write-DbDeployParameterLog function outputs all deployment parameters to the console for
    logging and troubleshooting purposes. This provides visibility into the configuration being
    used for the database deployment without exposing sensitive information like passwords.
 
.PARAMETER dacpacfile
    Specifies the path to the DACPAC file being deployed.
 
.PARAMETER action
    Specifies the deployment action to perform (e.g., Publish, Script, Report).
 
.PARAMETER TargetServerName
    Specifies the target SQL Server name. Used when connecting with individual server/database parameters.
 
.PARAMETER TargetDatabaseName
    Specifies the target database name. Used when connecting with individual server/database parameters.
 
.PARAMETER TargetConnectionString
    Specifies the complete connection string. Used as an alternative to individual connection parameters.
 
.PARAMETER TargetIntegratedSecurity
    Specifies whether integrated security is being used for the connection.
 
.PARAMETER EntraSecurity
    Specifies whether Microsoft Entra ID (Azure AD) authentication is being used.
 
.PARAMETER ServiceObjective
    Specifies the Azure SQL Database service objective (performance level).
 
.PARAMETER PublishFile
    Specifies the path to the publish profile file.
 
.PARAMETER Variables
    Specifies an array of SQLCMD variables to use during deployment.
 
.PARAMETER TargetTimeout
    Specifies the timeout value for the target connection.
 
.PARAMETER CommandTimeout
    Specifies the timeout value for SQL commands.
 
.PARAMETER sqlpackagePath
    Specifies the path to the SqlPackage.exe utility.
 
.PARAMETER Username
    Specifies the username for SQL Server authentication.
 
.PARAMETER scriptParentPath
    Specifies the parent path for deployment scripts.
 
.OUTPUTS
    None
    This function writes deployment parameters to the console but does not return any objects.
 
.EXAMPLE
    Write-DbDeployParameterLog -dacpacfile "MyApp.dacpac" -action "Publish" -TargetServerName "localhost" -TargetDatabaseName "MyDB"
     
    Logs the deployment parameters to the console for troubleshooting.
 
.NOTES
    Passwords are masked in the output for security purposes.
    This function is primarily used for logging and debugging deployment configurations.
#>

Function Write-DbDeployParameterLog {
    [CmdletBinding()]
    param(
        [Parameter(HelpMessage = "Path to the DACPAC file")]
        [string] $dacpacfile,
        
        [Parameter(HelpMessage = "Deployment action to perform")]
        [string] $action,
        
        [Parameter(HelpMessage = "Target SQL Server name")]
        [string] $TargetServerName,
        
        [Parameter(HelpMessage = "Target database name")]
        [string] $TargetDatabaseName,
        
        [Parameter(HelpMessage = "Target connection string")]
        [string] $TargetConnectionString,
        
        [Parameter(HelpMessage = "Whether integrated security is enabled")]
        [string] $TargetIntegratedSecurity,
        
        [Parameter(HelpMessage = "Whether Entra ID authentication is enabled")]
        [string] $EntraSecurity,
        
        [Parameter(HelpMessage = "Azure SQL Database service objective")]
        [string] $ServiceObjective,
        
        [Parameter(HelpMessage = "Path to publish profile file")]
        [string] $PublishFile,
        
        [Parameter(HelpMessage = "Array of SQLCMD variables")]
        [string[]] $Variables,
        
        [Parameter(HelpMessage = "Target connection timeout")]
        [string] $TargetTimeout,
        
        [Parameter(HelpMessage = "Command timeout")]
        [string] $CommandTimeout,
        
        [Parameter(HelpMessage = "Path to SqlPackage.exe")]
        [string] $sqlpackagePath,
        
        [Parameter(HelpMessage = "Username for authentication")]
        [string] $Username,
        
        [Parameter(HelpMessage = "Parent path for deployment scripts")]
        [string] $scriptParentPath
    )

    Write-host "Deploying database to server" 
    Write-host "DacpacFile : $dacpacfile" 
    Write-host "Action : $action" 
    if($TargetServerName -ne $null){
        Write-host "TargetServerName : $TargetServerName" 
        Write-host "TargetDatabaseName : $TargetDatabaseName" 
    }
    else {
        Write-host "TargetConnectionString : $TargetConnectionString" 
    }
    Write-host "TargetIntegratedSecurity : $TargetIntegratedSecurity" 
    Write-host "EntraSecurity : $EntraSecurity"
    Write-host "ServiceObjective : $ServiceObjective"
    Write-host "Profile : $PublishFile" 
    Write-host "Variables : $($Variables -join ' ')" 
    Write-host "TargetTimeout : $TargetTimeout" 
    Write-host "CommandTimeout : $CommandTimeout" 
    Write-host "SQLPackagePath : $sqlpackagePath" 
    Write-host "TargetUser : $Username" 
    write-host "scriptParentPath : $scriptParentPath"
    Write-host "TargetPassword : *************" 

}