2014-06-17 2 views
0

내가 첫 번째 쓰기 호스트를 선택할 수 있으며 두 번째로 점프하여 정보를 입력하지만 두 번째 쓰기 호스트에서 옵션을 선택하려고하면 같은 오류가 발생하지 않는다. 나는 그들 사이에서 무엇을 선택 하느냐가 중요합니다.왜 write_host가 명령으로 인식되지 않는가

오류가

용어 'write_host'는 cmdlet을, 기능, 스크립트 파일 또는 실행할 수있는 프로그램의 이름으로 인식되지 않는 것입니다. 이름의 맞춤법 검사 을 확인하거나 경로가 포함되어 있으면 경로가 올바른지 확인하고 다시 시도하십시오. 줄에 : 110 문자 : [] : (문자열 write_host :) + FullyQualifiedErrorId CommandNotFoundException : ObjectNotFound : 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 
    } 

}}}} 

답변

1
을 23 + write_host < < < <는 + CategoryInfo "설정 위치 당신은 준비 실행하려면"

귀하의 문제는이 라인이다 :

write_host "set location you want to run staging" 

이 cmdlet의 이름은 write-host하지 write_host입니다. 밑줄은 하이픈이어야합니다.

write-host "set location you want to run staging" 
+0

나는 작동하지 않으며 동일한 오류가 발생하지 않습니다. 이제는 선택 입력 후 동일한 위치에서 반복됩니다. – bgrif

+0

다른 질문이나 문제입니다. 이 답변을 수락 한 후 문제를 설명하는 데 필요한 최소한의 코드까지 코드를 압축하여 새로운 질문으로 게시하십시오. – alroc

+0

다른 질문에 대한 답변에서 -Match 매개 변수를 사용하지 않았기 때문입니다. 그것은 "(option1 | option2 | option3 ...)"("option1/option2/option3 ...)"이 아님 "..."이어야합니다. 이전 코드에서 복사 한 것이 내 코드에 있었을 것입니다. 나는 그것을 보았고 그것을 대답에 게시하기 전에 고쳐야했다. – TheMadTechnician

관련 문제