Quantcast
Viewing all articles
Browse latest Browse all 11

SharePoint 2010, PowerShell what’s the deal?

If you love PowerShell as much as I do, you should be aware of  how SharePoint 2010 takes full advantage of PowerShell. Over the past few months, I’ve been giving a presentation on managing SharePoint 2010 with PowerShell. It surprised me that the majority of people aren’t taking advantage of PowerShell or they don’t realize the benefits of learning PowerShell. I know there are thousands of blogs posts on the internet giving an introduction to PowerShell, but I’ve decided I would start writing a series of blog posts on using PowerShell to manage SharePoint 2010. Chances are if you are some type of IT administrator and your company decides to implement SharePoint, you will be stuck with managing the environment. So if you are in this position and you are looking around on the internet for resources for SharePoint 2010, chances are every resource you find somehow mentions PowerShell or gives you some type of PowerShell example. My goal for these blog posts is to  help SharePoint administrators learn PowerShell to manage their SharePoint environment. Many administrators will ask why should I take time to learn PowerShell to manage SharePoint. My answer to that is once you learn PowerShell to manage one product, you can take those skills and use PowerShell to manage other Microsoft and non Microsoft Products. We will start off with the basics of PowerShell from a SharePoint perspective and then each post we will dive into using PowerShell to perform every day SharePoint tasks.  In this blog post we will go over some terms that you will need to know when learning PowerShell. First lets login to our SharePoint server and open up the SharePoint Management Shell.

Image may be NSFW.
Clik here to view.
image

Now that we have PowerShell open, type the following command

Image may be NSFW.
Clik here to view.
image

Don’t worry about the exact syntax of the command, we will go into this later. The above command will return all Cmdlets that are available for managing SharePoint 2010. So at this point if you are new to PowerShell, you may be asking what are Cmdlets. Cmdlets are the powerful commands you use to do some specific function within PowerShell.  PowerShell has hundreds of cmdlets included by default for you to use to manage computers and other products. Cmdlets are always in the form of Verb-Noun, for example Get-SPFarm, Set-SPSite, Remove-SPWebApplication, Backup-SPFarm. One thing to note is that the noun portion of cmdlets are always singular. So now that we know what Cmdlets are, lets look at some important Cmdlets that will help you on your journey to becoming more comfortable with PowerShell. The first cmdlet is Get-Command. The Get-Command cmdlet will return all Cmdlets that are loaded in your current PowerShell session. An easy way to start exploring PowerShell, is to type Get-Command and start looking at the different Cmdlets available. Now that you typed Get-Command and you found a cmdlet that you want to know more about, lets figure out how to use that cmdlet. In this example, we are interested in the Get-SPSite cmdlet. To learn how to use this cmdlet, we will use the Get-Help cmdlet.

To use the Get-Help cmdlet, you type Get-Help and then the Cmdlet you want to learn more about.

Image may be NSFW.
Clik here to view.
image

The information provided by Get-Help is very useful . By default the above will return a description, the syntax, and some related cmdlets. So now we know that the Get-SPSite cmldet will return site collections that are currently in your SharePoint farm.  At this point you may still want to know how to use the cmdlet without reading all this additional information. Ok so type this into your shell

Image may be NSFW.
Clik here to view.
image

The above command is using the “examples” parameter to return examples on how to use the Get-SPSite cmdlet.  Believe it or not, the examples provided with most cmdlets are very useful. Not only does it give you an example, it gives you a description of the what the example will do. Another parameter to use with Get-Help is the “Full” parameter.

Image may be NSFW.
Clik here to view.
image

The above command will give us the tons and tons of information on the Get-SPSite cmdlet. It includes the description, examples, and also information on all the parameters included with the cmdlet.  Don’t worry if you don’t understand all the parameters or the concept of parameters now, I will dive deeper into parameters in a future blog post.

So now you know some basics of using PowerShell with Sharepoint, login to your SharePoint server and open the SharePoint Management Shell and use the cmdlets we covered so far to find some cmdlets that interests you. In the next blog post we will learn a couple more important cmdlets and actually start using some of these SharePoint cmdlets. If anyone is actually reading my blog and you have any questions shoot me an email at codygros@gmail.com or leave a comment. Also, if you want to learn how to do something specific with PowerShell or SharePoint let me know.


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 11

Trending Articles