I saw THIS posting over on Mark Minasi's forums that caught my eye. It gives you a random help file under the motto of: "A powershell help file a day, keeps Don Jones away". :-)
Don responded pointing out one of our new V2 cmdlets: Get-Random. Since that cat is out of the bag and Get-Random is so cool, let's explore it:
PS>Get-Help Get-Random
NAME Get-Random
SYNOPSIS Gets a random number or selects objects randomly from a collection.
SYNTAX Get-Random [-Count [<Uint32>]] [[-InputObject] [<psobject>]] [-SetSeed [<in t>]] [<CommonParameters>]
Get-Random [-Minimum [<Object>]] [[-Maximum] [<Object>]] [-SetSeed [<int>]] [<CommonParameters>]
DETAILED DESCRIPTION The Get-Random cmdlet gets a randomly selected number. If you submit a coll ection of objects to Get-Random, it gets one or more randomly selected obje cts from the collection.
Without parameters or input, "Get-Random" returns a randomly selected 32-bi t unsigned integer between 0 and Int32.MaxValue (0x7FFFFFFF, 2,147,483,647) .
You can use the parameters of Get-Random to specify a seed number, minimum and maximum values, and the number of objects returned from a submitted col lection.
RELATED LINKS
REMARKS For more information, type: "get-help Get-Random -detailed". For technical information, type: "get-help Get-Random -full".
PS> # Get A random numberPS> Get-Random1163375074PS>PS> # Get a random number within a rangePS> Get-Random -min 10 -max 1513PS>PS> # Get a random elementPS> "Tom","Dick","Harry" |Get-RandomDickPS> # Get a set of random elementsPS> "Tom","Dick","Harry" |Get-Random -count 3TomHarryDickPS> # Is it really random? yupPS> "Tom","Dick","Harry" |Get-Random -count 3DickHarryTomPS> # It works with any set of objectsPS> gps |get-Random -Count 2
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName------- ------ ----- ----- ----- ------ -- ----------- 361 26 51316 55864 151 225.73 1700 svchost 1570 16 68756 30300 276 457.43 2424 SearchIndexer
PS> gps |get-Random -Count 2
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName------- ------ ----- ----- ----- ------ -- ----------- 316 8 3004 7368 40 36.61 604 services 209 9 75740 137232 197 1,067.36 2760 dwm
At the end of the day, the cmdlets that manage the OS features need to come from those feature teams so you should not expect PowerShell to deliver a ton of those. For instance, the AD team needs to deliver the AD cmdlets, the network team needs to deliver networking Cmdlets. If you are not getting the cmdlets you need, you should knock on the doors of those feature teams. Don't suffer in silence, complain.
PowerShell will deliver some management cmdlets but by and large, we are going to focus our efforts on utility cmdlets that work against anyones objects and make it a good deal for those feature teams to develop cmdlets. Get-Random is just such a cmdlet. I'll bet you a dollar to a doughnut that no feature team would ever prioritize Get-Random but it turns out that all of their customers will use it at some point. PowerShell delivers it and thus the feature team's customers benefit. That's the deal - you invest in writting cmdlets/providers and we invest in ensuring that that was a great investement by delivering a ton of functions to your customers. How can you go wrong with that?
Enjoy!
Jeffrey Snover [MSFT]Windows Management Partner ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx