A long time ago I wrote a blog post about what I recognized as a very common error when starting to use PowerShell. You might have seen the error before:
The term ‘foobar’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
After reading the comments, I wanted to add a few other words about this error. Anther common way to stumble unto this error is by trying to run a cmdlet without having loaded the snapin or module containing that cmdlet.
If you are attempting to run a cmdlet from a product such as Sharepoint, Exchange, or Sql, and you are getting “The term is not recognized as the name of a cmdlet…” it is likely that the required snapin or module has not been loaded.
I might explain more about snapins and modules in a later blog post. For now, suffice it to say that they are both packages of cmdlets. Snapins were used in v1 of PowerShell. Modules came in v2 and have various advantages over snapins.
If you want to view what snapins are available to you, you can use the Get-PSSnapin cmdlet. “Get-PSSnapin –Registered” will show you all the snapins that have been registered on your computer. “Get-PSSnapin” will show you all the snapins that have been loaded.
To view the available modules, you can use the Get-Module cmdlet. “Get-Module –ListAvailable” will provide you a list of the modules that are available on your box for loading and “Get-Module” by itself will show you all the modules you have loaded.
I hope that helps.