?
Solved

Login to searial session with powershell

Posted on 2014-02-04
6
Medium Priority
?
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 70

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 70

Accepted Solution

by:
Qlemo earned 2000 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
Need protection from advanced malware attacks?

Look no further than WatchGuard's Total Security Suite, providing defense in depth against today's most headlining attacks like Petya 2.0 and WannaCry. Keep your organization out of the news with protection from known and unknown threats.

 
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 70

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

752 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