Solved

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

Posted on 2013-01-26
3
1,042 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 69

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 69

Expert Comment

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

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 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