PowerShell Team
Automating the world one-liner at a time…
Latest posts
Announcing Scripting games 2010
Scripting Guys have set the ball rolling for another fun filled and intresting edition of Scripting Games. You can see details here http://blogs.technet.com/heyscriptingguy/archive/2010/04/05/2010-scripting-games-all-links-on-one-page.aspx Grab this badge here!
Testing cmdlets with FxCop
Windows PowerShell wouldn’t be very useful without all the great cmdlets that actually manage specific technologies. We want to help cmdlet developers to create high-quality cmdlets. Today we announce availability of FxCop rules that can be used to verify compliance with some of the Cmdlet Design Guidelines as well as to find some of the common bugs. Installation Use the following procedure to download the required components: Use the following procedure to configure Microsoft FxCop to run FxCop Rules for Windows PowerShell on your code: Please refer to the FxCop Rules ...
“Falling is Learning – Just Focus on Having Fun”
Back in the days when our hair was on fire with security issues, we brought in a number of industry experts to educate us on developing secure software. This resulted in the Security Development Lifecycle which all our products now use. One of the best talks was a from a guy from the NSA who had a talk that was something along the lines of, “The zen of secure software”. In this talk he argued against the all-or-nothing mindset in favor of a model of constantly expanding the envelope. Any given moment, you evaluate what you need to do (in this case – to address security issues), you d...
Fun – Is W7 Too Good?
Sean Kearney (aka Ye110beard of Highway to PowersHell fame ) sent me a pointer to a fun video which posits that maybe W7 is TOO good. Just maybe it is so good that it will put IT Pros out of business. I think the exact opposite is true - I think PowerShell and the ability script the OS and products allows IT Pros to generate a ton of value and increase their integrated lifetime earnings. Still it is a fun video. You can catch it HERE. Enjoy! Jeffrey Snover [MSFT] Distinguished Engineer Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell ...
PSStandardMembers – The Stealth Property
Today I got the question I’ve looked into all of my.format.ps1xml files but I can’t find out where Format-List is getting its default view for, say, System.Diagnostics.Process: PS> ps |select -first 1 |fl Id : 7616 Handles : 543 CPU : 10.6860685 Name : CmdletDesigner How does it know it should display just these four properties? It seems there isn’t any ListControl view selected by this type within those formatting files... Excellent question! Let’s pick behind the curtain and see how it ...
Windows Management Framework Install Failure and Investigation
Since Windows Management Framework was released Oct. 2009, our customers have been excited about using PowerShell 2.0 on down-level OSes. Meanwhile, we also received feedback from both internal and external customers about our product issues. One of them is WMF install failure followed by the mysterious “The update does not apply to your system” error message. It is a blocking issue for some customers since they cannot get WMF successfully installed and the error message does not help much with a fix. 1. Reinstall. In some cases WMF(KB968930) had already been deployed on the machine by the system administrato...
Building on PowerShell: Execution Policies
One question we sometimes get asked is why Exchange changes PowerShell’s execution policy from “Restricted” to “RemoteSigned.” Doesn’t that lower PowerShell’s security? The "Restricted" execution policy isn't intended to be something that PowerShell users live with forever. It's a safe default that protects non PowerShell users from being impacted by PowerShell-based malware. For example, many home users had never used VBScript, but still got bitten by the flurry of WSH-based viruses that got mailed to them. PowerShell's Restricted execution policy solves this. To an attacker, a computer that has never used Power...
Workaround to Catch Exceptions from Import-CliXml
Recently, I came across an interesting bug in PowerShell. Let’s create a repro. First, we create a string “a” and generate an xml based representation of it using the Export-Clixml cmdlet. Since we need to have the class id, we pipe the string to format-table as shown in the example below. Here is the content of the xml file. Then, we remove the class id (in blue) and save the xml file. Next, we recreate an object using the import-cliXml cmdlet and we assign it to a variable, i.e. $a. We should get an exception because the class id is missing but, we do not. On the other hand, if we execute the same co...
Viewing Junctions with ‘dir’
One feature of the NTFS file system is the junction, which is similar to a short cut but works at the file system level. This lets you link one directory to another. There’s a tool called ‘junction’ available here that lets you manipulate junctions. When listing the contents of a directory, by default PowerShell doesn’t tell you which sub-directories are junctions. I wanted to be able to tell which ones were junctions when doing a ‘dir’. The way I did that was to copy the built in file system formatting file, modify it so that junctions are indicated, then load it with Update-FormatData: The file system format...