Solved

Login to searial session with powershell

Posted on 2014-02-04
6
371 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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.

Join & Write a Comment

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This article will help you understand what HashTables are and how to use them in PowerShell.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

10 Experts available now in Live!

Get 1:1 Help Now