0

I am trying to create script in which I can simultaneously access both Linux and Unix by using Powershell script, but I am facing problem whenever I run script it's opening Unix window but after existing from Unix session. I am able to access window session. I don't want to exit from Unix session. I want to use both. Please advise. Below is my code

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null     
$prompt = new-object -comobject wscript.shell 
$getPasswordAIX = Get-Credential -UserName "Avni" -Message "Enter  password"
$passwordAIX = $getPasswordAIX.GetNetworkCredential().password
$userAIX = $getPasswordAIX.GetNetworkCredential().username

#.\plink.exe mlismbc014 -i H:\davinsi.ppk -l $userAIX -pw $passwordAIX
.\plink.exe mlismbc014 -i H:\Key\unixKeys\avni.ppk -l $userAIX -pw $passwordAIX
echo %errorlevel%

Write-Host "Press any key to continue ..."    
$anyKey = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")    
$pshost = Get-Host              # Get the PowerShell Host.    
$pswindow = $pshost.UI.RawUI    # Get the PowerShell Host's UI.    
$newsize = $pswindow.BufferSize # Get the UI's current Buffer Size.   
$newsize.width = 150            # Set the new buffer's width to 150 columns.    
$pswindow.buffersize = $newsize # Set the new Buffer Size as active.    
$newsize = $pswindow.windowsize # Get the UI's current Window Size.    
$newsize.width = 150            # Set the new Window Width to 150 columns.    
$pswindow.windowsize = $newsize # Set the new Window Size as active.    
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null    
$prompt = new-object -comobject wscript.shell 
Matt
  • 14,906
  • 27
  • 99
  • 149
Avni
  • 11
  • Your script seems to be incomplete. Loading the VisualBasic assembly hints that you'd like to send keystrokes to the Unix system. Why are you mixing cmd (`echo %errorlevel%`) and creating a Cscript object too? – vonPryz May 10 '16 at 06:19
  • Hi ,I have this line to check the success or failure of the last executable run. – Avni May 10 '16 at 06:26
  • See this regarding the last exit code from processes: http://stackoverflow.com/questions/10666035/difference-between-and-lastexitcode-in-powershell – Charlie Joynt May 10 '16 at 08:14
  • is there any way we can restore session of unix – Avni May 27 '16 at 05:20

0 Answers0