SBS 2011 Essentials : PowerShell Cmdlets

sbse-conPowerShell is pretty cool. There does not seem to be much you can’t find out with it, or configure with it.

Not being a developer i struggle to build complex PowerShell scripts

, but it is really easy to do some basic stuff, like querying for a list of users, then applying further queries to the output, by using a pipe.

Of course piping output is nothing new, generally speaking.

I mainly use PowerShell for reporting on things, especially with Exchange, however having been recently working on an SBS 2011 Essentials Migration, i found some really useful PowerShell commands that i wanted to share.

First off, lets load up the SBS Essentials PowerShell Snapin.

Navigate to c:\program files\windows server\bin

1.ServerBin

Now enter the command : WssPowerShell.exe

2.ServerBinPS

Now you get your PowerShell prompt in a separate window.

3.PowerShell

Firstly, something that always bugged me was that i just get a prompt, i mean literally a prompt, (wow how GUI am i?)

Don’t get me wrong, i know how to program a Cisco Router/Switch from Hyper Terminal, so i am not completely devoid of command line skills, but when i learned that, at least i had a book to go from.

But if you don’t know what commands are available, you are kind of at a loss.

Help is at hand however, with this nifty little command.

Get-Help * | where-object { $_.Category –eq ‘CmdLet’ }

Enter that, and prepare to be amazed.

4.CmdLet

5.Scroll

Now don’t ask me why, finding a list of available PowerShell tools has to be so hard, i mean, it’s like they don’t want us to find them…

Also i am confident there is an easier way (there must be right?) but i had to hit Google to find this command,

Thanks to Gerado Lopzez for posting it.

The output from that command, will probably be a little overwhelming. So again, thanks to Mr Lopez we can add some syntax to our command, to get a little more use from it.

Get-Help * | where-object { $_.Category –eq ‘CmdLet’ } | Select Name,Synopsis,PSSnapIn | Sort Name

6.Sort

7.SortResult

The output here is a lot more useful, giving us a Synopsis, of what each tool actually does. Brilliant. However, a lot of it is actually cut off, and it exists only inside this window.

This is where i add a little of my own PowerShell magic.

Get-Help * | where-object { $_.Category –eq ‘CmdLet’ } | Select Name,Synopsis  | Sort Name | fl | Out-File c:\ToolsList.txt

8.ToolsList

I took away the PSSnapin column, added the Format List (fl) option, and also used the Out-File option to output our result to a text file.

ToolsList

Now we have a handy resource, for looking at all the available PowerShell commands on the box, the SBS Essentials commands are at the bottom, prefixed with WSS.

I suppose i need to give you an example of a command in action, so here is one i thought was very useful

Get-WssUser –name RobertPearman

This command will show me some information about my user account.

9.Name

Finding this command however, led me to another question, how do you find valid parameters for a CmdLet?

Well it is not as straight forward as you might think, of, you were expecting that?

Well happily, the output of our earlier CmdLet, has put all of that into our ToolsList.txt file for us

14.ToolsList

However, you may not want to refer back to that tools file every time you need to know which parameters are available, so to display all available parameters in the PowerShell session, you need to add a custom function.

Firstly, ill save you the trouble of scouring the internet, the answer is to be found here. Which seems to have been posted by @halr9000 so thanks go to him.

Unfortunately for me, being a novice PowerShell scripter, although those posts gave me the function i needed, it didn’t actually tell me how to create it. (or maybe i just couldn’t see it) Anyway, following this post i worked out i could just save that code into a notepad document with a PS1 extension, and then call it from a PowerShell session. Easy if you know how.

My preference is to use the PowerShell ISE (Integrated Scripted Environment) which you may have to install, it is a feature and can be installed using the following command.

DISM /Online /Enable-Feature /FeatureName=MicrosoftWindowsPowerShellISE

10.ISE

11.ISE

So lets put it into practice using the Add-WssUser as a test CmdLet.

. c:\users\dfunk\param.ps1 –CmdLet Add-WssUser | format-table –AutoSize

12.Param

13.Param1

There are some other ways you can get the Function to work, but for simplicity ill stick to this one.

SBS 2011 Standard does not appear to have the same type of PowerShell cmdlets available as SBS Essentials, however that should not stop you exploring what is possible by using PowerShell.

Have a look at the TroubleShootingPack module, and the additional CmdLets that makes available, some really cool tools!

ToolsPack

Hope this was interesting, at the very least you have read about a few PowerShell commands, which you can use in front of people or clients, because the Command Line always impresses people!

About Robert Pearman
Robert Pearman is a UK based Small Business Server enthusiast. He has been working within the SMB IT Industry for what feels like forever. Robert likes Piña colada and taking walks in the rain, on occasion he also enjoys writing about Small Business Technology like Windows Server Essentials or more recently writing PowerShell Scripts. If you're in trouble, and you can find him, maybe you can ask him a question.

4 Responses to SBS 2011 Essentials : PowerShell Cmdlets

  1. Philipp says:

    Thanks, quite useful, though Get-WssUser does not seem to be present on my SBS 2011 Essentials (others are there, weird).

    There is a typo in one of your samples: It reads “_$.Category” whereas “$_.Category” would be correct I assume.

  2. I know this is an old post, but I am running SBS 2011 Standard and I cannot find the file WssPowerShell.exe. What’s up with that?

Leave a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: