×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hi, I need to pass a User name and

Hi, I need to pass a User name and

Hi, I need to pass a User name and

(OP)
Hi,
I need to pass a User name and a Pass to the PS script.
I tried to find it online but could not.
Ant idea how to do this?

CODE --> shell

Invoke-Command -Computer DESK-2.domain.somecorp.com -Scriptblock {C:\Python39\python.exe 'C:\temp\DT_Col\HN.py'} 

thank you.

RE: Hi, I need to pass a User name and

It's not clear what you are trying to do. Authenticate to a remote device or run a program as another user on a remote device?

This PowerShell Remoting: The Ultimate Guide article may help explain authentication.

RE: Hi, I need to pass a User name and

(OP)
Hi, thank you for helping me with this!
I need to accomplish two things.
1. get the Process list from a remote computer
2. start a script on a remote host

I tested both one-liners, I ran it from my laptop to get the Process list and to execute a Python script on my desktop.
Of course, both PCs have the same user accounts and ran without any problems.
What I need is to execute both scripts from my server on a bunch of remote hosts and the hosts do not have my account in the Admin group.
But I have a user name/password to log in to the Hosts,
I just need to add '$credentials' to the script. I do not know how to do that.
Here are the one-liners I have:

CODE --> shell

Invoke-Command -ComputerName someone-desk2 -ScriptBlock {Get-Process} 

Second one-liner:

CODE --> shell

Invoke-Command -Computer someone-DESK2 -Scriptblock {python.exe 'C:\Python_Test\Remote_Access\rem-Exec-01.py'} 

Thank you!

RE: Hi, I need to pass a User name and

Have you checked that the remote devices have PowerShell Remoting enabled, i.e. WinRM and Remote Registry enabled/running, including their firewalls accepting remote PS commands?

RE: Hi, I need to pass a User name and

(OP)
Yes, 'PowerShell Remoting enabled' - is enabled.

Thank you.

RE: Hi, I need to pass a User name and

Are you in a domain or workgroup environment? If it's domain then I cannot help... no experience.

If it's a workgroup then I assume you're using basic authentication?

What response do you get when you enter:

CODE -->

Test-WsMan someone-desk2 

I'm in a workgroup environment and can test the PSRemoting connection by either IP address or computername. So, for example, I enter:

CODE -->

test-wsman DESKTOP-MSV1KLP 

... and see this:



This shows a successful connection. You should see similar.

Next, I invoke:

CODE -->

Invoke-Command -ComputerName DESKTOP-MSV1KLP -ScriptBlock {Get-Process} -credential user 

(where 'user' is the account I'm going to use) and the credential request dialog appears for me to authenticate:



That's how you authenticate in a workgroup environment - using the -credential parameter to invoke the challenge/response. Are you seeing similar?

Note that this is only a temporary session and will close after the command or scriptblock ends.

If I wanted to run several cmdlets then I would use:

CODE -->

Enter-PSSession -ComputerName DESKTOP-MSV1KLP -Credential user 

Once the session is established, your prompt will change to show the remote computer you’re connected to and you should then be able to execute any number of cmdlets directly without you having to continually add the Invoke-Command cmdlet and the remote computername.

Hope this helps...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close