Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 ?

share|improve this question

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

share|improve this answer
    
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 '13 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 MCSA Jan 7 '13 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. –  Stephen Connolly Jan 7 '13 at 13:11
    
I don't know. but I think you are right. –  Red Swan Jan 7 '13 at 13:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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