It would be nice to be able to pass parameters between steps. I'm doing something similar. I would have liked to do the related T-SQL in a separate step. However, I execute the T-SQL in same PSH step.
invoke-sqlcmd -Query $query `
-serverinstance $serverinstance -database 'master' -QueryTimeout 600
RandyHelpdesk: Perhaps Im not the only one that does not know what you are doing. 😉