We help IT Professionals succeed at work.
Get Started

Running a powershell script from batch file as DIFFERENT USER (non interactively)

Krishna V
Krishna V asked
on
1,853 Views
Last Modified: 2015-05-07
Hi Friends,
 I need your valuable suggestion on how I can achieve the following:

OS: Windows

In short: I want to understand how can I RUN a Powershell script from a Batch file by providing domain credentials (NON-INTERACTIVELY).

Here is my scenario in detail:

I have a java program, started by a Service, which creates a batch file on the fly which will have to invoke a powershell script during runtime and the powershell script has some cmdlets which need to RUN as DOMAIN USER, otherwise those cmdlets wont return values. Currently I am using a work around like.. I am running the service as the domain user and able to get the data from cmdlets, but when I run the service as Local System account I am not getting data from cmdlet.

Can you please suggest a better way to accomplish what i wanted.. getting data from cmdlet without having to run the service as domain user. Can I run the powershell script as DOMAIN USER from within the batch file. The program which creates the batch file has domain user credentials (username & password).

Please note that WinRM is disabled in the environment, otherwise I could use Invoke-Command with details and make things work without having to run the service as domain user.

Thanks a lot for your valuable suggestions.

Regards,
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE