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 
4
  • 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? Commented May 10, 2016 at 6:19
  • Hi ,I have this line to check the success or failure of the last executable run. Commented May 10, 2016 at 6:26
  • See this regarding the last exit code from processes: stackoverflow.com/questions/10666035/… Commented May 10, 2016 at 8:14
  • is there any way we can restore session of unix Commented May 27, 2016 at 5:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.