SharePoint & PowerShell 101: Finding Cmdlets
January 4, 2011 4 Comments
I recently did a post on Listing all available PowerShell commands in SharePoint 2010. That is all well and good, if you want to manually browse through all of them. But what if you want to search for them?
Get-Command
Get-Command is a highly useful cmdlet in PowerShell. Today we are just going to use a basic functionality of it, to help us find and locate the cmdlets we need to use. Today, we need to do some work with the User Profile Service. However, we don’t know what the command names are that we need to use, only that we need to use them. For that, we can use Get-Command. If you need to figure out how to use the Get-Command cmdlet, run
Get-Help Get-Command
Which will return the following information about the cmdlet
This will return the usage of the Get-Command cmdlet. We are just going to use the –Noun switch to pass in our parameters.
Let’s start looking at the basics… we’re looking to find commands relating to the User Profile Service. So, let’s try searching for a noun of Profile
Get-Command –Noun Profile
Nothing is returned… oh right, it would appear that the Get-Command is literal, not a wildcard. However, we can use a wildcard character to help us search, as we have no idea what the name of the command is. Let’s try searching for *Profile*, that should do the trick.
Get-Command –Noun *Profile*
Hooray, results! However, we cannot see the entire name of the results returned. For that, we can use the Select-Object cmdlet.
Fore information on using that, try this in the PowerShell console
Get-Help Select-Object
So, let’s only pull the Name property in our results of the Get-Command
Get-Command -Noun *Profile* | Select-Object –Property Name
Much better! We can further refine these by adjusting our Noun, to just look at ProfileService
Get-Command -Noun *ProfileService* | Select-Object -Property Name
And there we go! Hopefully this helps you in your quest to add PowerShell to your arsenal of SharePoint management and development tools.
I’d love to hear what else you would like to learn about – leave me information in the comments!
Pingback: SharePoint Daily » Blog Archive » SharePoint Trends for 2011; Firefox Beats IE in Europe; Cloud Computing Predictions
Pingback: SharePoint Daily
Pingback: SharePoint 2010: Recopilatorio de enlaces interesantes (XVI)! « Pasión por la tecnología…
Pingback: SharePoint 2010: Recopilatorio de enlaces interesantes (XVI)! - Blog del CIIN