When combining multiple Powershell scripts together as indicated by @mklement0 in his answer on Converting Multiple Powershell Scripts to EXE, is there a way to take into account nested script calls?
For example, I have "base" powershell scripts that handle REST API calls, and build request headers for more complex API calls. Then I have my main script that takes all of that work and builds out a procedural script. Similar to include/using statements, I call the needed scripts from the top of my main script and pass in base variables that are needed.
Example:
MainScript.ps1
. .\Base\WebRequests.ps1 -BaseUri $BaseUri -Token $Token
Invoke-BaseWebRequest -Variable1 $Variable1 -Variable2 $Variable2
\Base\WebRequests.ps1
param(
[String] $BaseUri,
[String] $Token
)
function Get-CustomRequest{
param(
[String] $Variable1,
[String] $Variable2
)
process{
script code
}
When performing the combining, is there a non-convoluted way to take into account the "include" statements and remove them so that it will bundle the scripts in proper procedural order in order that the functions can be used from the main script?