I am looking to leverage Azure Pipelines to replace an existing scheduled task that I have running on an on-premise server. Today, my script connects to a SQL database using the dbatools PowerShell module, runs a few queries, and dumps the files to a specific file format. Then uploads these files to an SFTP server.
My repository contains the SQL files to run, the Get-Data.ps1 script that connects to the database, retrieves the data, and exports it to the format necessary. I also have a Send-Data.ps1 which takes the files created from Get-Data.ps1 and SFTPs them to an SFTP server.
I've got 1 PowerShell script to retrieve and output the data to files, and another to SFTP the files to an SFTP server.
My Send-Data.ps1 script has 3 parameters - localpath, remotepath and credential. I am curious how I could have the Get-Data.ps1 script write as output the data required for "localpath" parameter, and then pass this to the Send-Data.ps1 as a 2nd task in the pipeline?
Additionally, is there a recommended way to pass credentials into PowerShell scripts in a pipeline? I saw where I can leverage the library to store a username and password to pass into a script. But this isn't a PSCredential object. Would I do this by using Azure Keyvault? Could I do it using the library and the inline script part of the pipeline? Or read it in from the key vault/library, create the PSCredential object, store that as a variable(?) and pass it into the PowerShell script task?