PowerShell Team
Automating the world one-liner at a time…
Latest posts
Getting Alternate Streams (Verbose, Progress, Debug) with the PowerShell API
Dozens of people could write dozens of books on all of the cool stuff we improved in V2 of PowerShell. One of the nice little things we did was give a more understandable API than Pipeline (which is the class you can use to invoke code from C# in V1). This API is called the PowerShell API, and one of the improvements it makes is the ability to get to alternate data streams. Alternate data streams are a particularly fun thing about PowerShell. While you can have a lot of output streams in DOS, it was anyone's guess exactly what any of them were. PowerShell has several alternate data streams that...
Rename-Drive : Renaming Drives with PowerShell & WMI
.CmdletName { font-size:large } .CmdletSynopsis { font-size:medium } .CmdletDescription { font-size:medium } .CmdletParameters { font-size:medium } th { font-size: medium; font-style: italic } table { border: 1 } Shane Burton from Compellent just asked me to help him rename a drive with PowerShell. It's possible to rename drives using a couple of different WMI classes, Win32_Volume, and Win32_LogicalDisk. You change the drive by setting a property name on the WMI Object (Label in Win32_Volume, and VolumeName in Win32_LogicalDisk), and then putting it back...
Managing Server Features with PowerShell Cmdlets on Windows 2008 Server R2 Beta
If you have used Windows Server 2008, probably you had experience with managing server features. Server Manager is a traditional way to install/uninstall server features. On Windows 2008 Server R2 Beta, Windows PowerShell provides a new approach to managing server features via Server Manager PowerShell cmdlets. This blog will walk through installing server features with these cmdlets. To use the Server Manager cmdlets, we need to import servermanager module by running the PowerShell command “Import-Module servermanager”. The reason is that these cmdlets are encapsulated in the servermanager module, and are not a...
Design of Script Friendly APIs, lessons from $psISE
Cmdlets are high level, task-oriented abstractions. The implementation of cmdlets can talk to anything: Web services, COM objects, WMI objects, .NET objects – anything. Depending upon how developers design their API, they can make it easier or harder to write cmdlets. Now that you can write cmdlets in PowerShell itself, here are some tips for designing your API so that it can be easily scripted against and turned into a set of cmdlets using PowerShell Just because the Object Model lives in .NET land, doesn’t mean we can’t make it easier to use for scripte...
PowerShell Wizard
Ye110wbeard did it again. Check THIS out. Loads of fun. Experiment! Enjoy! Engage! Jeffrey Snover [MSFT] Windows Management Partner Architect Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
A Bit More On BITS
I was in a meeting yesterday talking about BITS and what an awesome service it was. I described what it did and how it allowed people to avoid a wide range of low-class, pain in the butt problems. The question then became, "why isn't everyone using it?" That's a darn good question. The answer is that we have not educated people about it. I aim to fix that. I wrote an earlier blog on BITS HERE. Alex Ng has just written a nice blog about it HERE. Check it out, try it out, tell a friend (and consider the internet a friend). Experiment! Enjoy! Engage! Jef...
Debugging PowerShell Script Using the ISE Editor
Hi writers and consumers of buggy scripts.This post explains the basics of the Graphical Debugger in the ISE. There’s a lot of good stuff, with some tips and tricks.The debugger support got the cmdlets and user interface. The cmdlets include Enable/Disable/Get/Set/Remove-PsBreakpoint and Get-PsCallStack.The general feel is to place breakpoints across the script, continue (F5) to jump from breakpoint to breakpoint, and step over, step into, and step out to move around. You can also get the call stack, and hover over variables to get their values.BreakpointsLine breakpoints are easy to add, with F9 or c...
Why Should I Test With PowerShell?
Today, on our internal discussion list, someone asked if there were any advantages to testing with PowerShell versus testing with C#. I was able to come up with 10 quick reasons to test with PowerShell: I hope these reasons help convince other software testers to use PowerShell. It can really make testing a lot simpler. Hope this helps, James Brundage [MSFT]
Using PowerShell to Protect Against Conficker (Enabling and Disabling AutoRun.inf)
On the front page of MSN.com today, there’s details about a new worm, Conficker, that spreads using the good old fashioned autorun.inf tricks. It infects USB drives so that, when you plug the drive into another computer, it automatically runs and infects the machine. The article mentioned a post on Nick Brown’s blog that instructs you on various ways to disable autorun.inf files and gives a .REG file for disabling autorun.inf. Here’s the .REG file: Recently, I’ve started to like taking small registry hacks and turning them into functions, so here’s a pair of functions that I wrote to automate t...