I have this script here:
SQLPS
$ppath = Read-Host "Please enter the package database folder path"
$client = Read-Host "Enter Client name"
$date = Get-Date -Format "yymmdd"
$sqlsrvname = Read-Host "Please enter the sql server name"
$deploytype = Read-Host "Is there a server instance? (1) Yes (2) No"
switch($deploytype){
1 {$Instance = Read-Host "Please Enter instance name"
cd -Path $ppath
.\sqlpatchremote.ps1 -DBServer $sqlsrvname –dbinstance $Instance –client $client –mainline HTFS –datefolder $date –targetenv $sqlsrvname}
2 {cd -Path $ppath
.\sqlpatchremote.ps1 –dbserver $sqlsrvname –client $client –mainline HTFS –datefolder $date –targetenv $sqlsrvname }
default {"Invalid Selection"}
}
It creates input that calls another script to create SQL databases. I now have to combine the two scripts into one script. Is there an easy way to do that so that I can take the input this script normally generates and launch the other script?
The beginning of the other script looks like this:
param
(
[String] $PatchVersion = "RemoteVersion",
[String] $DBNameList = "alldatabases",
[String] $Client = "noclient",
[String] $DBServer = "localhost",
[String] $DBInstance = "",
[String] $TargetEnv = $(throw, "Please specify a target environment"),
[String] $MainLine = $(throw, "Please specify a mainline"),
[String] $DateFolder = $(throw, "Please specify a date folder")
)
This is the output my script generates that normally launches the second script: .\sqlpatchremote.ps1 -DBServer $sqlsrvname –dbinstance $Instance –client $client –mainline HTFS –datefolder $date –targetenv $sqlsrvname
So I guess I'm not sure where I am suppose to plug the output of my script to launch this other script from within the same script. I mainly want them to act like separate scripts even though they're in the same script. Or blend them together which I imagine would be more complicated. Also, I need it to be compatible with Windows Server 2008, so I cant use newer PowerShell commands. Unfortunately, a lot of our clients are stuck in the past and still use Windows Server 2008.
Read-Hoststatements, why can't your user just use the parameter names and tab completion?read-hostbecause I like to spell out all the parts of my script to make it nice and easy to follow. Also my boss wants me to have users input the paths manually so that's why they're there. I'm kinda OCD when it comes to scripting I like it to look a certain way and spelling out my commands and making it user friendly is just my preference. Also my boss is the one who wants me to combine these scripts into 1. I was happy running them separately before.read-hostis necessary because that information is always different.