Solved

Login to searial session with powershell

Posted on 2014-02-04
6
373 Views
Last Modified: 2014-02-07
Hi Experts,

I have to configure a UPS through the console port. Is it possible to automate this with Powershell?

I found out how to connect, but can i also login using a powershell script? And if thats possible, can i run some commands in hyperterminal to configure the device?
0
Comment
Question by:SvenIA
  • 3
  • 3
6 Comments
 
LVL 68

Expert Comment

by:Qlemo
ID: 39833221
There are different approaches. You can use scriptable clients like Putty, or the classic SendKeys way well-known from VB Script code. SendKeys simulates keystrokes, and works well if you don't need to respond to prompts in different ways.
0
 
LVL 7

Author Comment

by:SvenIA
ID: 39834904
Ok thanks, but can it be done just by using PowerShell?
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39835771
SendKeys can be used in Powershell. This should give you a start. The COM port settings are stored in UPS.ht. ~ is the same as {ENTER}, a carriage return.
cls
Set-StrictMode -version latest

Add-Type -Assembly Microsoft.VisualBasic
Add-Type -Assembly System.Windows.Forms

$term = start-process "C:\HyperTrm\UPS.ht" -PassThru

[Microsoft.VisualBasic.Interaction]::AppActivate($_.ID)
sleep -m 100
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
sleep -m 500
[System.Windows.Forms.SendKeys]::SendWait("TheUser~")
sleep -m 500
[System.Windows.Forms.SendKeys]::SendWait("ThePassword~")
sleep -m 500
# and so on

Open in new window

0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 7

Author Comment

by:SvenIA
ID: 39841289
Thanks, this does give me a start. However, i got one problem left. I use a portable version of HyperTerminal on Windows 7. I associate the ups.ht file with HyperTerminal. But when i try to open it by doubble clicking it, or by using the script, i get this error. Tried it on different computers....

Error
Can i fix this? What are alternatives for HyperTermal wich can save connection configurations?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39841321
You can use hypertrm C:\temp\ups.ht to start it with a configuration.
For repairing the double-click action, open RegEdit, go to
  HKEY_CLASSES_ROOT\htfile\Shell\open\command
and check the entry there. It should display something like
   "C:\Program Files\Windows NT\HYPERTRM.EXE" %1
but with the correct path, of course.
0
 
LVL 7

Author Closing Comment

by:SvenIA
ID: 39841409
I got it working!! Thanks so much for your quick and accurate help!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This article will help you understand what HashTables are and how to use them in PowerShell.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now