In the SqlFunctions module, we have two functions. Get-DailyProductsSalesQuery will return the contents of the SQL file. Note that within the function, we get a reference to the module. We then use the FileList property to get the full path of the SQL file:
function Get-DailyProductSalesQuery{ $module = Get-Module SalesDashboardModule; $filePath = $module.FileList | Where { $_ -like '*DailyProductSalesQuery*'} $sql = [System.IO.File]::ReadAllText($filePath).Trim(); Write-Debug "Sql: $($sql)"; return $sql;}
Before returning the SQL script, we use Write-Debug to show the message on the console. The output of this command will be visible only when running in debug mode.