Solved

Powershell: command doesn't wait for input in a remote session

Posted on 2013-01-26
3
1,006 Views
Last Modified: 2013-01-26
I try to run a RunAs command in a remote powershell session, but it doesn't let me enter a password, immediately inviting to run another command:
PS C:\Windows\system32> Enter-PSSession comp1
[comp1]: PS C:\Users\admin\Documents> runas /user:user@domain.loc hostname
Enter the password for user@domain.loc:
[comp1]: PS C:\Users\admin\Documents>

Open in new window

How do I enter a password in a remote session?
Thank you.
0
Comment
Question by:PavelTMN
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 38822453
RunAs will not work in a remote PS session. The password prompt is coded in a way it hides the input, and that is not supported. Since you configured WinRM already, it is much better to use invoke-command:
invoke-command -Computer comp1 -Script { hostname } -Credentials "user@domain.loc"

Open in new window

or use the -Credential parameter of Enter-PsSession.
0
 
LVL 1

Author Comment

by:PavelTMN
ID: 38822579
Thanks for clearing that out.

The problem with invoke-command is that a limited user, that you want to use credentials of, must have a right to create a PS session to the remote computer which I obviously don't want to give. Even if you do invoke-command in an already admin-opened session it still requires that right for an alternate creds account.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38823087
Then you might want to use SysInternals PsExec instead.
0

Featured Post

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.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

920 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