I have bit interesting requirements. My client want to develop the Sharepoint 2010 administration UI from Java application. So I suggest him to user Sharepoint web services. As we all know its good to use. but he want to perform this on command based. So I suggest to user of batch files with Powershell cmdlets. I am not sure with this architecture. but can somebody focus me up , how to use power shell commands (cmdlets) with the bat file ?

1 Answer 1


You can execute them like any other script which you schedule in your servers Task Scheduler (if that is what you want to do on a regular basis). First, build your powershell script as you usually do and place the file in an appropriate folder. Then build your bat-file calling the powershell script - like this:

powershell .\test.ps1 arg1

You can have multiple argument while calling the script as long as you handle them in your script.

If you need to write .bat-files using powershell, you can use the Out-File command, well described in the article Using the Out-File Cmdlet. Like the following:

Get-Process | Out-File c:\scripts\test.txt

More to read: Use bat to start Powershell script

  • Thanks Benny, In fact This is the way how to execute the .bat file with Power shell... I need how to write bat file with sharepoint cmdlets .. any example ?
    – Red Swan
    Jan 7, 2013 at 12:43
  • @RedSwan Isn't it just to make a standard .txt file with the extention .bat from a regular File writing as in Using the Out-File Cmdlet? That's what I would do.
    – Benny Skogberg
    Jan 7, 2013 at 12:49
  • 1
    Don't forget that by default PowerShell won't allow execution of scripts. To ensure that you don't experience problems add the parameter '-ExecutionPolicy Bypass' to the powershell command line so that the policy is temporarily disabled for this invocation. Jan 7, 2013 at 13:11
  • I don't know. but I think you are right.
    – Red Swan
    Jan 7, 2013 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.