Script modules

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.

Advanced functions can be called with the -Debug parameter. ...

Get PowerShell for Office 365 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.