DEV Community

Discussion on: 7 tips to automate your daily DWH/BI developer life using PowerShell and Excel

Collapse
 
andreroobyn profile image
Andrzej Rusin

Great article! I also find PowerShell very powerful for automating some repetitive or administrative tasks. Sometimes in combination with Excel, when for example I need to build some SQL query for a complex but well structured view. You can easily write a formula that will output the SQL construct for the specific field and then extend it to other rows. Then in PowerShell you can loop through the column and concatenate into single query.
I find it very convenient to loop through the specific column in a name table as follows:

$rng = $wks.Range("queryTable[ColumnName]")
foreach($cell in $rng) {
    # do something on cell
}
Enter fullscreen mode Exit fullscreen mode

Having full list of columns you can easily build a SQL query and then with the use of PowerShell update the view definition in for example SAP PowerDesigner, as automating it with PowerShell is just unbelievably easy :)

$powerDesignerApp = New-Object -ComObject "PowerDesigner.Application"
Enter fullscreen mode Exit fullscreen mode

From there once the object is created you can traverse down the object model to check what is there and what can be used. It is just very quick and efficient to develop a script and over time improve it or add functionalities.
Bottom line is that for me it is one of the most useful tools in my inventory :)
Cheers!

Collapse
 
rgogloza profile image
rgogloza

Thanks for the comment!

Excel. PowerShell and PowerDesigner is a time saver.

This com object import in PowerShell can be also used to connect to Word, and for example generate documentation out of it.