?
Solved

How to execute a Powershell script with a batch file

Posted on 2011-02-14
3
Medium Priority
?
1,508 Views
Last Modified: 2012-05-11
Experts,

             How would I execute a powershell file test.ps1 from a batch file so that no user interaction would be needed. (i.e. the user would not need to start up Powershell-if possible)?

Thanks, Missymadi
0
Comment
Question by:missymadi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:missymadi
ID: 34890756
What if the Powershell required a snapin "ActiveRolesManagement" ? And the script I have is a powershell script. How would I execute that from a batch file. Such as, an sql file is executed by a batch file.
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 34890772

Add it in the PS script :)

Add-PsSnapIn Quest.ActiveRoles.ADManagement

Then all you need in your batch file is this:

PowerShell yourscript.ps1

You can have more, you can prevent PS closing, or other things, but for the most part you need nothing more.

Chris
0

Featured Post

Need protection from advanced malware attacks?

Look no further than WatchGuard's Total Security Suite, providing defense in depth against today's most headlining attacks like Petya 2.0 and WannaCry. Keep your organization out of the news with protection from known and unknown threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question