I have an .exe that needs to run via GPO. I attempted to do it via a batch script, however it needs to run on user machines and this requires elevation as they aren't local admins. Rather than touching each machine to setup a local admin and having the GPO run off that. I'd like to set up powershell script to start an elevated session, either PS or CMD it doesn't matter.
The big blocker is detecting the host name of each machine so I can use:
New-PSSession hostname -Auth CredSSP -cred domain\adminuser
I toyed with the idea of having it detect the IP address and then do a DNS lookup for the user, but aside from the issues with that, I imagine this is far more work than necessary. I attempted to research on here for similar issues, but I'm unable to find a similar situation with that above blocker.
Batch File:
@echo off
if exist "C:\Program Files\directorypath\service.*" goto END
if exist "C:\Program Files (x86)\directorypath\service.*" goto END
"\\SERVER\FOLDER\installer.exe" --mode unattended
:END
Using runas didn't seem entirely appropriate for this issue. And I'd rather like to avoid putting my password or a generic admin password in a plain-text file.