Author Posts

January 20, 2017 at 9:33 pm

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!

January 20, 2017 at 9:52 pm

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.

January 20, 2017 at 9:53 pm

I do know the usernames and passwords of each user.

January 20, 2017 at 9:58 pm

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.

January 20, 2017 at 10:01 pm

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?

January 20, 2017 at 10:07 pm

Wow.

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

Go with God.

January 20, 2017 at 10:12 pm

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.

January 20, 2017 at 10:14 pm

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.

January 20, 2017 at 10:15 pm

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