?
Solved

How to execute a Powershell script with a batch file

Posted on 2011-02-14
3
Medium Priority
?
1,531 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
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
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 anti-spam), the admin…
Loops Section Overview

864 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