我可以选择第一个写主机并跳转到第二个输入信息但是当我尝试在第二个写主机上选择一个选项时,无论我在它们之间选择什么,我都会得到相同的错误。
错误是
术语' write_host'不被识别为cmdlet,函数,脚本文件或可操作程序的名称。检查拼写 如果包含名称,或者包含路径,请验证路径是否正确,然后重试。 在行:110 char:23 + write_host<<<< "设置您想要运行的位置" + CategoryInfo:ObjectNotFound:(write_host:String)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException
function Execute-MySqlcommand {param( [string]$Server, #the host of the SQL server
[string]$Database1, #the name of the database
[System.Data.MySqlclient.MySqlcommand]$Command) #the command to execute (name of stored command)
$mysqlConnection = new-object System.Data.MySqlclient.MySqlConnection
$MySqlConnection.ConnectionString = "DROP_VIEW DATABASE.BTXADDR;DROP_VIEW DATABASE.BTXSUPB;CREATE_VIEW DATABASE.BTXADDR FOR DATABASE1.DATABASE1S2.BTXADDR;CREATE_VIEW DATABASE.BTXSUPB FOR DATABASE1.DATABASE1S3.BTXSUPB"
$MySqlConnection.ConnectionString = "TRUNCATE TABLE DATABASE1.DATABASE1S2.BTXADDR;TRUNCATE TABLE DATABASE1.DATABASE1S3.BTXSUPB; INSERT INTO DATABASE1.DATABASE1S3.BTXSUPB SELECT * FROM DATABASE1.DATABASE1S2.BTXSUPB; select count(*) from DATABASE1.DATABASE.BTXADDR; select count(*) from DATABASE1S.DATABASE.BTXADDR; select count(*) from DATABASE1.DATABASE.BTXSURB; select count(*) from DATABASE1S.DATABASE.BTXSUPB;"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $mysqlConnection
$mysqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$mysqlConnection.Close()
if ($Result -gt 0) {return $True} else {return $False}
}
function execute-MySqlcommand {param( [string]$Server, #the host of the SQL server
[string]$DataBase2, #the name of the database
[System.Data.MySqlclient.MySqlcommand]$Command) #the command to execute (name of stored command)
$mysqlConnection = new-object System.Data.MySqlclient.MySqlConnection
$MySqlConnection.ConnectionString = "DROP_VIEW DATABASE.BTXADDR;DROP_VIEW DATABASE.BTXSUPB;CREATE_VIEW DATABASE.BTXADDR FOR DATABASE2.DATABASE2MS2.BTXADDR;CREATE_VIEW DATABASE.BTXSUPB FOR DATABASE2.DATABASE2S3.BTXSUPB"
$MySqlConnection.ConnectionString = "TRUNCATE TABLE DATABASE2.DATABASE2S2.BTXADDR;TRUNCATE TABLE DATABASE2.DATABASE2S3.BTXSUPB; INSERT INTO DATABASE2.DATABASE2S3.BTXSUPB SELECT * FROM DATABASE2.DATABASE2S2.BTXSUPB; select count(*) from DATABASE2.DATABASE.BTXADDR; select count(*) from DATABASE2S.DATABASE.BTXADDR; select count(*) from DATABASE2.DATABASE.BTXSURB; select count(*) from DATABASE2S.DATABASE.BTXSUPB;"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $mysqlConnection
$mysqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$mysqlConnection.Close()
if ($Result -gt 0) {return $True} else {return $False}
}
function Execute-MySqlcommand {param( [string]$Server, #the host of the SQL server
[string]$DATABASE3, #the name of the database
[System.Data.MySqlclient.MySqlcommand]$Command) #the command to execute (name of stored command)
$mysqlConnection = new-object System.Data.MySqlclient.MySqlConnection
$MySqlConnection.ConnectionString = "DROP_VIEW DATABASE.BTXADDR;DROP_VIEW DATABASE.BTXSUPB;CREATE_VIEW DATABASE.BTXADDR FOR DATABASE3.DATABASE3S2.BTXADDR;CREATE_VIEW DATABASE.BTXSUPB FOR DATABASE3.DATABASE3S3.BTXSUPB"
$MySqlConnection.ConnectionString = "TRUNCATE TABLE DATABASE3.DATABASE3S2.BTXADDR;TRUNCATE TABLE DATABASE3.DATABASE3S3.BTXSUPB; INSERT INTO DATABASE3.DATABASE3S3.BTXSUPB SELECT * FROM DATABASE3.DATABASE3S2.BTXSUPB; select count(*) from DATABASE3.DATABASE.BTXADDR; select count(*) from DATABASE3S.DATABASE.BTXADDR; select count(*) from DATABASE3.DATABASE.BTXSURB; select count(*) from DATABASE3S.DATABASE.BTXSUPB;"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $mysqlConnection
$mysqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$mysqlConnection.Close()
if ($Result -gt 0) {return $True} else {return $False}
}
function Execute-MySqlcommand {param( [string]$Server, #the host of the SQL server
[string]$DATABASE4, #the name of the database
[System.Data.MySqlclient.MySqlcommand]$Command) #the command to execute (name of stored command)
$mysqlConnection = new-object System.Data.MySqlclient.MySqlConnection
$MySqlConnection.ConnectionString = "DROP_VIEW DATABASE.BTXADDR;DROP_VIEW DATABASE.BTXSUPB;CREATE_VIEW DATABASE.BTXADDR FOR DATABASE4.DATABASE42.BTXADDR;CREATE_VIEW DATABASE.BTXSUPB FOR DATABASE4.DATABASE4S3.BTXSUPB"
$MySqlConnection.ConnectionString = "TRUNCATE TABLE DATABASE4.DATABASE4S2.BTXADDR;TRUNCATE TABLE DATABASE4.DATABASE4S3.BTXSUPB; INSERT INTO DATABASE4.DATABASE4S3.BTXSUPB SELECT * FROM DATABASE4.DATABASE4S2.BTXSUPB; select count(*) from DATABASE4.DATABASE.BTXADDR; select count(*) from DATABASE4S.DATABASE.BTXADDR; select count(*) from DATABASE4.DATABASE.BTXSURB; select count(*) from DATABASE4S.DATABASE.BTXSUPB;"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $mysqlConnection
$mysqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$mysqlConnection.Close()
if ($Result -gt 0) {return $True} else {return $False}
}
function Copy-File {
#.Synopsis
# Copies all files and folders in $source folder to $destination folder, but with .copy inserted before the extension if the file already exists
param}($DATABASE0980453.pkg,"d/DATABASE1/code_stg","d/DATABASE2/code_stg","d/DATABASE3/code_stg","d/DATABASE4/code_stg")
# create destination if it's not there ...
#mkdir $destination -force -erroraction SilentlyContinue
foreach($original in ls $source -recurse) {
$result = $original.FullName.Replace($source,$destination)
while(test-path $result -type leaf){ $result = [IO.Path]::ChangeExtension($result,"copy$([IO.Path]::GetExtension($result))") }
if($original.PSIsContainer) {
# mkdir $result -ErrorAction SilentlyContinue
# } else {
copy $original.FullName -destination $result
}
}
write-host "This script sets up DATABASE Staging"
$ProductionDistro = Read-Host -Prompt "Which production do you `enter code here`want to run?(TC/MonsterLock/Cyc)"
While($ProductionDistro -notmatch "(TC/MonsterLock/Cyc)"){
write-host "You have entered an error" -ForegroundColor Red
write-host "You must type TC or MonsterLock or Cyc"
write-host "you typed $ProductionDistro"
write-host "This script sets up DATABASE Staging"
$ProductionDistro = Read-Host -Prompt "Which production do you `enter code here`want to run?(TC/MonsterLock/Cyc)"
}
write-host "Sets up location you want to run staging"
$ElementDistro = Read-Host -Prompt "Which Element do you want to run? (DATABASE1/DATABASE2/DATABASE3/DATABASE4/ALL)"
While($ElementDitro -notmatch "(DATABASE1/DATABASE2/DATABASE3/DATABASE4/ALL)") {
write-host "you have enterd an error" -ForgroundColor Red
write-host "You must type DATABASE1 or DATABASE2 or DATABASE3 or DATABASE4 or ALL"
write-host "you typed $ElementDistro"
write-host "set location you want to run staging"
$ElementDistro = Read-Host -Prompt "Which Element do you want to run? (DATABASE1/DATABASE2/DATABASE3/DATABASE4/ALL)"
}
if ( $ElementDistro = $DATABASE1 )
cd /d/DATABASE1/code_stg
function Execute-MySQLCommand {param( [string]$Server, #the host name of the SQL server
[string]$DATABASE1, #the name of the database
[System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = "DATABASE_CONNECT_STRING=DSN=DATABASE1;Description=DATABASE1;Trusted_Connection=Yes;WSID=Server;DATABASE=DATABASE1;DATASET=DEFAULT"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $sqlConnection
$sqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$sqlConnection.Close()
if ($Result -gt 0) {return $TRUE} else {return $FALSE}
}
install ../DATABASE0980453.pkg
}
if ( $ElementDistro = $DATABASE2 ) {
cd /d/DATABASE2/code_stg
function Execute-MySQLCommand {param( [string]$Server, #the host name of the SQL server
[string]$DATABASE2, #the name of the database
[System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = "DATABASE_CONNECT_STRING=DSN=DATABASE2; Description=DATABASE2; Trusted_Connection=Yes;WSID=Server;DATABASE=DATABASE2;"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $sqlConnection
$sqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$sqlConnection.Close()
if ($Result -gt 0) {return $TRUE} else {return $FALSE}
install ../DATABASE0980453.pkg
}
if ( $ElementDistro = $DATABASE3 ) {
cd /d/DATABASE3/code_stg
function Execute-MySQLCommand {param( [string]$Server, #the host name of the SQL server
[string]$DATABASE3, #the name of the database
[System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = "DATABASE_CONNECT_STRING=DSN=DATABASE3;Description=DATABASE3;Trusted_Connection=Yes;WSID=Server;DATABASE=DATABASE3;"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $sqlConnection
$sqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$sqlConnection.Close()
if ($Result -gt 0) {return $TRUE} else {return $FALSE}
install ../DATABASE0980453.pkg
}
if ( $ElementDistro = $DATABASE4 ) {
cd /d/DATABASE4/code_stg
function Execute-MySQLCommand {param( [string]$Server, #the host name of the SQL server
[string]$DATABASE4, #the name of the database
[System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = "DATABASE_CONNECT_STRING=DSN=DATABASE4;Description=DATABASE4;Trusted_Connection=Yes;WSID=Server;DATABASE=TF90PVS;"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $sqlConnection
$sqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$sqlConnection.Close()
if ($Result -gt 0) {return $TRUE} else {return $FALSE}
}
install ../DATABASE0980453.pkg
if ( $ElementDisrto = $ALL ){
function Execute-MySQLCommand {param( [string]$app03bsi, #the host name of the SQL server
[string]$DATABASE1,$DATABASE2,$DATABASE3,$DATABASE4, #the name of the database
[System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = "(DATABASE_CONNECT_STRING=DSN=DATABASE1;Description=DATABASE1;Trusted_Connection=Yes;WSID=Server;DATABASE=DATABASE1;DATASET=DEFAULT;),(DATABASE_CONNECT_STRING=DSN=DATABASE2; Description=DATABASE2; Trusted_Connection=Yes;WSID=Server;DATABASE=DATABASE2;),(DATABASE_CONNECT_STRING=DSN=DATABASE3;Description=DATABASE3;Trusted_Connection=Yes;WSID=Server;DATABASE=DATABASE3;),(DATABASE_CONNECT_STRING=DSN=DATABASE4;Description=DATABASE4;Trusted_Connection=Yes;WSID=Server;DATABASE=TF90PVS;)"
$Command.CommandType = 1 # 1 is the 'Text' command type
$Command.Connection = $sqlConnection
$sqlConnection.Open()
$Result = $Command.ExecuteNonQuery()
$sqlConnection.Close()
if ($Result -gt 0) {return $TRUE} else {return $FALSE}
install ../DATABASE0980453.pkg
}
}}}}
答案 0 :(得分:1)
你的问题在于这一行:
write_host "set location you want to run staging"
cmdlet的名称为write-host
,而不是write_host
。下划线应该是连字符:
write-host "set location you want to run staging"