Powershell Script for Sharepoint 2010 via Batch help needed

Windows 2012 R2 Server
IIS 8.5
SharePoint 201 SP2 FARM

Have a PowerShell script that backs up the entire SharePoint farm.
On the Windows 2012 R2 server we have PowerShell 4.0 running which is installed on Windows 2012.
When I installed SharePoint it created a shortcut for SharePoint Management Powershell
I can invoke SharePoint cmdlets no issue

No I need to automate my Farm backup script.

So I created a batch file farm-backup.cmd
powershell.exe -noprofile .\Farm-Backup.ps1

Open in new window

When this runs I get this error

16-Jul-2015 06:00:25      Warning: An error occurred whilst checking for the My Site Host. Reason: Microsoft SharePoint is not supported with version 4.0.30319.34209 of the Microsoft .Net Runtime.

This tells me that PowerShell 4 is being used and SharePoint 2010 will not work with PowerShell v4

So my question is how can I invoke PowerShell V2 so that my batch file will work?


Thanks in advance
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steven CarnahanNetwork ManagerCommented:
Did you try:

powershell.exe -version 2.0 -noprofile .\Farm-Backup.ps1

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thomas GrassiSystems AdministratorAuthor Commented:

First thanks for the quick response

No I did not try that

Will try that and post results
Thomas GrassiSystems AdministratorAuthor Commented:

That worked it is now running

Thank you
Steven CarnahanNetwork ManagerCommented:
Glad to be of help.  I have used it with version 2 and 3 loaded but wasn't sure if it would work with version 4.  :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.