0
kitty/PuTTY 세션을 여는 데 사용하는 powershell 명령이 있습니다. 형식이 경우는 server.TWO에 저를 필요에 내가 무엇을 넣어 명령 행 인수에 상관없이 server.three 저를 가지고,하지만해야Powershell이 명령 줄 인수에 액세스 중
.\my_sshCommand three
입니다. 명령 줄에 매개 변수가 없으면 server.TWO가 기본값이됩니다. PowerShell에서 루프를 만드는 방법을 모르므로 명령을 하드 코드합니다. 나는 왜 명령이 스크립트에 입력 한 명령 줄 인수에 관계없이 항상 else 절을 수행하는지 설명하지 않습니다.
param(
[array] $ComputerName
)
ForEach ($Computer in $ComputerName) {
IF($Computer -match 'one') {
$Computer="server.one"
Write-Output "c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
$Command="c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
}
IF($Computer -match 'two') {
$Computer="server.TWO"
Write-Output "c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
$Command="c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
}
IF($Computer -match 'three') {
$Computer="server.three"
Write-Output "c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
$Command="c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
}
IF($Computer -match 'four') {
$Computer="server.four"
Write-Output "c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
$Command="c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected]$Computer -pw pizza"
}
ELSE {
Write-Output "c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected] -pw pizza"
$Command="c:\Working\Kitty.exe -load `"capser profile`" -ssh [email protected] -pw pizza"
}
}
Invoke-Expression $Command