Open PS1 file from batch as another user

Miguel 1 Reputation point
2022-06-06T17:57:51.803+00:00

Hello,
I was wondering if someone can help me with the following. The script asks for credentials, but it does not open the PS1 file.
Suggestions?

@echo off
SET /P AdminName="Enter Bang Account: "
RUNAS /netonly /user:ENTSC\%AdminName% "powershell -File \\Server\Harvester.ps1"
pause
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2022-06-08T15:04:31.73+00:00

    You need a share name too.

    \Server\Share\Harvester.ps1

    Your PowerShell execution policy might also block remote scripts. You should get some error message from PowerShell.

    PowerShell -noexit -executionpolicy bypass -file \\Server\Share\Harvester.ps1  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.