Quantcast
Channel: CloudShare Community » visual studio 2013
Viewing all articles
Browse latest Browse all 6

How to execute PowerShell scripts and cmdlets in Visual Studio!

$
0
0

As SharePoint developers, sometimes we need to do some IT Pro stuff such as creating a PowerShell Scripts for doing common tasks: deploying .WSP solutions to the farm, create some auxiliary lists, etc. In order to create and execute these scripts you can use the SharePoint 2013 Management Console or the Microsoft ISE (Integrated Shell Script Environment) as your scripting tools. However, most of the time we are using Visual Studio for our programming stuff and we don’t feel happy switching from Visual Studio to the scripting tool we have chosen…so the question around the corner is if there is a way to execute PowerShell Scripts in our favorite development tool.

Fortunately, the answer is “almost yes” (at the end of the post you’ll understand why the word “almost” appears in this statement) thanks to the PowerShell Tools for Visual Studio you can download from the Visual Studio Gallery:

http://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597

In this article I will show you how to use these PowerShell Tools for executing PowerShell cmdlets in the IDE (Integrated Development Environment):

  • Once you have downloaded and installed the PowerShell Tools in your CloudShare development environment, open Visual Studio 2013 (VS 2013) and create a new project in the IDE. In the “New Project” window you’ll find that there is a new “PowerShell Script Project” project template. Just create a new project using this template.

image

image

  • Once you have fixed the execution scripts issue, you can execute any PowerShell script in Visual Studio, do some debugging adding breakpoints to the script, etc.

image

  • For instance, if you have defined any variable in your script you have the possibility to inspect the content using the out of the box capabilities.

image

  • Of course, in the Visual Studio output Window you can see the results of the script execution. Additionally, the Call Stack window allows you to see how the script is being executed by the IDE. If you are wondering if it is possible to execute SharePoint cmdlets in Visual Studio, the answer is “No for the moment”. Unfortunately, the PowerShell Tools for Visual Studio are not able to load the PowerShell SnapIn for SharePoint because is x64 based.

image

  • Finally, you can verify that for any PowerShell command you want to use you have intelligence ready to help you in writing your PowerShell scripts in Visual Studio.

image

  • For instance, if you execute the Get-Process cmdlet you’ll get in the Visual Studio Output Window all the process currently executing in your CloudShare environment.

image

And that’s all about how to execute PowerShell scripts in Visual Studio. Happy CloudSharing!!


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images