M
M
Morrowind2019-10-24 11:54:49
PowerShell
Morrowind, 2019-10-24 11:54:49

How to run an exe file on a remote PC using powershell?

I have a problem that I've been dealing with for a week now.
I wrote a script to install SQL software in a couple of hours, but I still can't run the exe file correctly.
The problem is that the odbc.exe driver does not want to run as an administrator.
If you just take it with your hands and run it through the admin (right-click), then everything is fine. If you just click it, it will seem to show that it has been installed, but in fact it is not (this point is clear to me).
I did the following options.

$lock = Get-Credential "doman\admin" 
Invoke-command - computername $Computer - Credential $lock - ScriptBlock {
Start- process - Filepath "C:\New\odbc. exe -argumentlist  - Verb runAs}

I used to substitute keys: / s / i and many others.
Tried wmiclass in Invoke-command, invoke-item, even cmd and just specifying the exe file without commands in Invoke-command.
The result is the same, the script works, but does not run from under the admin. In PS ISE I go from under the administrator.
msi file is not possible to get, only exe is available.
What am I doing wrong and what haven't I tried yet?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Morrowind, 2021-07-01
@hekkaaa

Try to use these solutions
https://habr.com/ru/company/pc-administrator/blog/...
From my experience I will say that in the code you do not have enough credential (log \ pass) to execute the command.
In those conditions where I wrote a similar script, alas, it didn’t even work because there were strict IS policies and no one was going to change them. That's why sometimes it's a dead number.
You can try workarounds by throwing the batch file into TEMP and launching it if through powershell. An alternative is accessing CMD via Invoke-command.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question