Whoah. Thanks to @timalexander for passing this one to me. Look at how long that scrollbar is! Click here or on the picture to grab ‘em!
PoshCode is a highly modified pastebin web app (this version written in PHP) which some of us in the community have been using for some time to store our reusable script components.
This tool, formerly hosted on powershellcentral, now has its own domain. Joel “Jaykul†Bennett has been doing a lot of work on it lately, which you can read about here.
New features include:
- RSS feed for new entries
- Improved navigation by author
- Cleaner front page
Once I get around to it, this site will be linked to properly from PowerShellCommunity.
Go forth and share (and steal!) scripts!
I want to really thank Greg Hughes and Richard Campbell with RunAsRadio for interviewing myself and Carter Shanklin at TechEd 2008 last month. They just posted episode 64 titled “Using Powershell with VMWare!†I think you can guess the topic.
If you are an IT Pro, you should definitely check out their podcast. The show primarily deals with Windows system administration topics, but it’s a very broad coverage including applications used on top of the OS.
As some know, I’m busy writing a book. During the course of writing said book, I’ve come across a need to quickly look up the parameters for cmdlets and several particulars thereof. Such was the inspiration for my new favorite function: Get-Parameter. It goes like this:
PS > gpm Get-EventLog ParameterSet: LogName Name Type IsMandatory Pipeline ---- ---- ----------- -------- LogName String True False ComputerName String[] False False Newest Int32 False False InstanceId Int64[] False False Index Int32[] False False EntryType String[] False False Source String[] False False Message String False False AsBaseObject SwitchParameter False False ParameterSet: List Name Type IsMandatory Pipeline ---- ---- ----------- -------- ComputerName String[] False False List SwitchParameter False False AsString SwitchParameter False False
Now gpm is actually a meta-function which I created to customize the output for a particular need for my book. Here’s what Get-Parameter looks like by default.
PS > Get-Parameter -Cmdlet Set-VM | Format-Table Name Type ParameterSet IsMandatory Pipeline ---- ---- ------------ ----------- -------- VM VirtualMachine DefaultSet False True Name String DefaultSet False False MemoryMB Nullable`1 DefaultSet False False NumCpu Nullable`1 DefaultSet False False GuestId String DefaultSet False False AlternateGue... String DefaultSet False False OSCustomizat... OSCustomizat... DefaultSet False False Server VIServer[] DefaultSet False False RunAsync SwitchParameter DefaultSet False False Description String DefaultSet False False VM VirtualMachine SnapshotSet False True Name String SnapshotSet False False Snapshot Snapshot SnapshotSet False True OSCustomizat... OSCustomizat... SnapshotSet False False Server VIServer[] SnapshotSet False False RunAsync SwitchParameter SnapshotSet False False
Instead of posting the code here, I’ve decided to start using the PoshCode script repository and its various evolving features. So, you can find the code at the Get-Parameter listing. Also, here is a direct download link. Should open right in Notepad or however you’ve got that configured.
Update: I’ve updated the link to point to the latest version as of 12/21/08.
Update: (2009-06-30) The ‘gpm’ meta-function got removed from PoshCode at some point, so I’m posting it here for posterity:
function gpm ($Cmdlet) { Get-Parameter $Cmdlet |
ft name,type,is*,pipe* -GroupBy parameterset -AutoSize }
Update (2009-09-24): I’ve changed the script to work standalone instead of as a function.
Everyone be sure to attend the PowerShell Virtual User Group meeting #6 which Marco Shaw is hosting this Tuesday at 8pm EDT. You can find all the details on this blog post.
Check out this star-studded cast (preceding me anyway)!
Agenda:
8:00PM-8:10PM: Introduction
8:10PM-8:40PM: Bruce Payette (Microsoft)
8:40PM-9:10PM: Wassim Fayed (Microsoft)
9:10PM-9:40PM: Hal Rottenberg
9.40PM-9:50PM: Closing
You can register to attend on clicktoattend.com. It’s free, of course.
I’ll be giving a lecture titled “Introduction to Managing VMware with PowerShellâ€.
Update: Slides are now on slideshare.net.
Here’s a simple little df (disk free from Unix) function for PowerShell:
function df ( $Path ) {
if ( !$Path ) { $Path = (Get-Location -PSProvider FileSystem).ProviderPath }
$Drive = (Get-Item $Path).Root -replace "\\"
$Output = Get-WmiObject -Query "select freespace from win32_logicaldisk where deviceid = `'$drive`'"
Write-Output "$($Output.FreeSpace / 1mb) MB"
}
One of the features which Tobias has been working on lately that I appreciate a lot is the Help Center. What do I like so much about it? There is no static compilation step! This means the list of cmdlets which you see matches the snapins you have loaded at the time. I add new snapins all the time so I find this extremely useful when I need to look up a parameter.
I’m not sure if the currently available beta builds work exactly this way–they might. Another cool feature not shown is an Office-like text box in the toolbar in which you can type cmdlet names to pull up the help.
Karl says he’ll be blogging the steps required today sometime (it might be up by the time you see this).
Portable PowerShell from karl prosser on Vimeo.
Attachment: r_and_j.xml$romeo = [xml] (Get-Content .\r_and_j.xml)
$romeo.PLAY.ACT | select -exp scene | select -exp speech |
? { $_.speaker -eq 'NURSE' } | select -first 3 | fl
SPEAKER : Nurse
LINE : {Now, by my maidenhead, at twelve year old,, I bade her come. What,
lamb! what, ladybird!, God forbid! where's this girl? What, Juliet
!}
SPEAKER : Nurse
LINE : Your mother.
SPEAKER : Nurse
LINE : Faith, I can tell her age unto an hour.
Thanks to Wassim from Microsoft for passing the XML along. I think the original work is out of copyright by now.




