O'Reilly logo

PowerShell for Office 365 by Prashant G Bhoyar, Martin Machado

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required