PowerShell Team
Automating the world one-liner at a time…
Latest posts
PowerShell Folksonomy – Are You In?
A while ago I did some experimentation with a PowerShell folksonomy. The idea was to tag internet content (blogs, comments, newsgroup replies, etc) with unique tags that search engines would pick up and make it easier to find exactly the information you needed. This effort stemmed from an documentation battle we had over the use of the term cmdlet. This was a word that I made up to describe PowerShell commands but I wanted to invoke the idea that these were tiny things that were composed with other tiny things to solve big problems. One of reasons I was hardcore on this idea of a cmdlet b...
Where Did That Come From?
Have you ever found yourself asking the question, "where did THAT come from?"? In PowerShell we try to give you mechanisms you can use to answer questions like that. We spend extra resources (memory, cpu cycles, etc) to do this because we focus in the performance of the PEOPLE using our software instead of the performance of the code. When something goes pear-shaped, what matters is how quickly a person can figure out what is going on and fix it. We've talked quite bit about this in the context of the rich error information we gather but in this blog I'm going to d...
Converting to Array
When you run a PowerShell pipeline, that pipeline might return 0, 1 or many items. If you are assigning the results of that pipeline to a variable, you will get $null, 1 item or an array of items respectively. Sometimes, you won't care about the different types returned, but at other times, you'll actually prefer to force the results to always be an array. In those cases, you can use @( ... ). As in: $a = @(get-childitem) That will evaluate the statements enclosed within the parentheses and collect the results into an array. If there are no results, then you'll get an arra...
Stopping Every Instance of PowerShell.exe (except the one I'm in)
Our Test Architect just dropped by my office and pitched me a PowerShell question with a nice, quick answer. He wanted to stop every process of a particular name, except for the instance that was running the script. You can do this in one nice pipeline: Get-Process Powershell | Where-Object { $_.ID -ne $pid } | Stop-Process Get-Process takes a positional parameter (name), which is a wildcard that supplies the name of the process. It returns back a bunch of ProcessInfo objects, which have a property, ID (the process ID). $pid is a variable that will tell you the current process ID in Powe...
JAOO Talk
Last year I was delighted to be invited to give a talk at JAOO conference. This is a great language conference. The thing I was delighted to discover is that the while it had Microsoft content (AndersH gave one of the keynotes), the bulk of the people and content was non-Microsoft. This allowed me to give a different kind of a talk. It allowed me to go back to the basics and explain what were were doing and why we were doing it to a group of people that didn't necessarily have any background and were potentially not particularly friendly towards Microsoft. (I've got a funny story abo...
#requires your scripts
Recently, I saw someone that had developed a script on the CTP3 drop and was then having trouble running it on v1 of PowerShell. Eventually it turned out that he was using v2 features in his script. Most of you know that we are trying to keep the next version of PowerShell compatible with v1 and I encourage you to report any problems that you might have in that area. Unfortunately, v2 being compatible with v1, doesn’t mean v1 is compatible with v2. After seeing that, I started thinking about people sharing v2 scripts on the web and the problems they might cause someone that didn’...
Diff between Windows PowerShell versions
PowerShell MVP Oisín Grehan has done a really good job in getting the diff between PowerShell releases. V1 and CTP3 http://www.nivot.org/2009/02/04/DifferencesBetweenPowerShell10RTMAndPowershell20CTP3Win7Beta.aspx CTP2 and CTP3 http://www.nivot.org/2008/12/23/PowerShell20CTP3HasArrived.aspx Thanks a lot Oisín. Osama Sajid [MSFT]
Console Application (Non) Support in the ISE
There are some limitations on how the ISE interacts with console applications you need to be aware of, for apps like ftp and netsh.First of all, the ISE Runs console apps that don’t require user input just fine.For example, “ping www.microsoft.com” and “cmd /c dir /s”Piping also works fine in the ISE,For example, PS C:\Users\ibrar> "show mode" | netshnetsh>onlineAutomation in scripts, that don’t require user interventions should be fine.However, if you run “cmd /k” which requires input, the ISE will be stuck, and you’ll have to stop the pipeline, using Ctrl-Break or pressing the stop button.It can get annoy...
Managing Windows Update From PowerShell
James O’Neil just posted how to manage Windows Update with Windows PowerShell Here’s a quick sample of what he can do: Add-WindowsUpdate –Auto to download updates and reboot if needed, Set-WindowsUpdateConfig –n 4 –i to schedule updates (Including the merely recommended) and Get-WindowsUpdateConfig Check it out: http://blogs.technet.com/jamesone/archive/2009/01/27/managing-windows-update-with-powershell.aspx Hope this Helps, James Brundage [MSFT]