Powershell command help

This topic contains 8 replies, has 2 voices, and was last updated by  Don Jones 9 months ago.

  • Author
    Posts
  • #62289

    Travis N
    Participant

    I think my request is going to be SUPER simple for somone on this forum. I'm NOWHERE near great at powershell, on a scale of 1-10 im a 1. Hoping somone would love to help a new sys-admin out here.

    I'm looking to run an exe with command line switches remotley on a computer, as the currently logged in users.

    I'm hoping to load the scrpit, it asks for what computer i'd like to migrate (dialog box for pc name), then issue a command to that computer and run the exe that would be called under the user thats currently logged into that computer.

    Hope that made sense!

  • #62292

    Don Jones
    Keymaster

    This: "that would be called under the user thats currently logged into that computer" is nearly impossible, given the security model in Windows. You would need to know that user's name and password, at the very least.

  • #62293

    Travis N
    Participant

    I do know the usernames and passwords of each user.

  • #62296

    Don Jones
    Keymaster

    Oh. OK. Well, that's vaguely disturbing from a security perspective, but sure.

    You then run into a second problem. All of the means we have to remotely start processes can, by default, only be done by Administrators. But, if you do it as Administrator, then it'll run under Administrator, not the logged-on user. If you do it as the logged-on user's name and password, you'll get an Access Denied.

    Again, you're going up against a very serious and deeply rooted part of Windows' security setup. These things are designed to prevent malware from spreading, and they're very embedded in the OS architecture.

  • #62299

    Travis N
    Participant

    I'm going to scare alot of people on this forum, but I just recently got this position, so i have no grounds to change their views. That being said.

    Users are local admins on their computer here
    we have a spreadsheet with usernames and passwords.

    With that being said, if the users had local admin, would that allow this script to run as them remotely?

  • #62302

    Don Jones
    Keymaster

    Wow.

    Either use WMI to create a new remote instance of Win32_Process, or use Invoke-Command to run the EXE.

    Go with God.

  • #62304

    Travis N
    Participant

    What exactly would the invoke-command scrpitliet look like? like i said i am HORRIBLE with powershell, so if its just a matter of changing some information in a command i can do that, but creating one from scratch i have no idea how to do it.

  • #62305

    Don Jones
    Keymaster

    So, that would be "read the help."

    Help Invoke-Command

    If you run Update-Help first, it'll contain numerous examples. I'd far prefer to get you started learning this than to just give you commands, but they all tend to have excellent help examples.

    Additionally, go get "Learn Windows PowerShell in a Month of Lunches, 3rd Edition." There's an entire chapter on Remoting (Invoke-Command) which will take you under 45m to read, and it will change your life and career. Guaranteed.

  • #62307

    Don Jones
    Keymaster

    (run Update-Help, then run "Help Invoke-Command -ShowWindow", for best results)

You must be logged in to reply to this topic.