Question

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 ?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top