PowerShell Team
Automating the world one-liner at a time…
Latest posts
Windows PowerShell in Action: Working With Text and Files in Windows PowerShell (Part 2)
ScriptCenter has a couple chapters of Bruce Payette's awesome book: Windows PowerShell in Action. You can (and should) read part 2 of chapter 10 at: http://www.microsoft.com/technet/scriptcenter/topics/winpsh/payette2.mspx Part 2 focuses on file processing. Enjoy Jeffrey Snover [MSFT]Windows PowerShell/MMC 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
Windows PowerShell in Action: Working With Text and Files in Windows PowerShell
ScriptCenter has a couple chapters of Bruce Payette's awesome book: Windows PowerShell in Action. You can (and should) read chapter 10 at: http://www.microsoft.com/technet/scriptcenter/topics/msh/payette1.mspx Here what ScriptCenter says about it: PowerShell is Microsoft's next-generation command line and scripting solution. It combines the interactive capabilities of traditional shells such as bash or zsh with the programmability of scripting languages such as Perl or Ruby. Because PowerShell is based on .NET, it's capable of doing things in a shell environment that were previously only possibl...
-ErrorAction and -ErrorVariable
Let me take a minute to tell you about 2 of my favorite things in Windows PowerShell: -ErrorAction and –ErrorVariable You may have heard me talk about being maniacal about doing a great job with error handling ... this is one the cornerstones of our architecture. Here is the background: Cmdlets are implemented by subclassing a base class. The engine reflects against this class looking for public properties that have a .net attribute on them identifying them as a PARAMETER. Why is this a good idea? Well think about it, the base class can also have public properties with the ...
PowerShell Month Begins!!!!
Windows PowerShell Scripting Contest on TechNet ScriptCenter (Nov 1 – Dec 15 2006) Want a chance to win one of over 150 prizes, including one of two, all-expenses paid trips to Redmond, WA to meet the Windows PowerShell team? Or maybe one of 12 Xbox 360 Core gaming machines? Or one of the dozens of prizes provided by PowerGadgets or a copy of Sapien’s PrimalScript 4.1 and Windows PowerShell: TFM book. That’s more than $13,000 in prizes and over 150 prizes. And all you have to do is write a Windows PowerShell script and submit it as part of the Windows PowerShell Scripting Sweepstakes. Enter as often as yo...
Power and Pith
In our newsgroup, Benny asked the question, “How to get subdir items with full path name?” ClaudioG64 responded: PS> get-childitem C:\ | foreach-object -process { $_.FullName } Dreeschkind replied that we had pithier ways of doing it posting: PS> gci C:\ | % { $_.FullName } It was at this point that I realized that many of you don’t have a function that many of us in the team use. So put your seatbelts on and try this one out: PS> ${function:...} = { process { $_.($args[0]) } }PS> gci c:\ | … FullName With Windows PowerShell, you can be Powerful and Pithy! Enjoy Jeffrey Snover [MSFT]Windows...
Turning the dial to 11 with Custom TypeConverters
If you are the sort of bloke that likes to turn the dial to 11, you should check out Abhishek's recent blog entry on Custom TypeConverters: http://abhishek225.spaces.live.com/Blog/cns!13469C7B7CE6E911!191.entry Much of the power of Windows PowerShell comes from the type coercion capabilities of our ObjectFlow engine. This is what allows PowerShell to eliminate tons of low-class, impedance-mismatch programming minutia and allows you to focus on the problem you are trying to solve. There are a number of things we do here including type creation, using a type's PARSE method, leveraging the .NET...
Windows PowerShell Font Customization
Windows PowerShell Font Customization <Today we have a guest blog entry from another team in Microsoft> There’s a new set of fonts that have been developed and released this year bundled with the betas for the new Windows and Office. These 6 fonts are collectively called The Microsoft ClearType Font Collection. They are designed for on-screen reading with ClearType enabled. In short, this means that if you have an LCD display then text written in these fonts will be more readable. One of these fonts in particular, Consolas, is of interest to us programmers, shell scripter...
Windows PowerShell Exit Codes
Windows PowerShell Exit Codes PSMDTAG:FAQ: How can my script control the PowerShell exit code? Answers: 1. A normal termination will set the exitcode to 0 2. An uncaught THROW will set the exitcode to 1 3. The EXIT statement will stop the process and set the exitcode to whatever is specified. c:\>powershell -noprofile -command "Write-output Test"Testc:\>echo %errorlevel%0c:\>powershell -noprofile -command "Write-output Test; throw 'ERROR'"TestERRORAt line:1 char:25+ Write-output Test; throw ...
Live Syntax Checking
Sapien PrimalScript's support for WIndows PowerShell continues to get better. The latest addition is Live Syntax Checking. This is particularly useful for people who are starting out with PowerShell which is basically everyone at this point. Checkout their blog post: http://sapien.eponym.com/blog/_archives/2006/10/14/2416634.html It's also worth checking out the list of new features found in PrimalScript 4.1: http://www.primalscript.com/psnextpreview.asp It's pretty impressive stuff. Jeffrey Snover [MSFT]Windows PowerShell/MMC ArchitectVisit the Windows PowerShell Team blog at: &n...