PowerShell Team

Automating the world one-liner at a time…

Philosophy of Automation

 In my previous post about Boolean Values And Operators I made the following point: "PowerShell has a rich notion of TRUE/FALSE because it dramatically reduces the overhead and junk that you need to deal with when doing your work."  This philosophy flows from Whitehead's observation:   Civilization advances by extending the ...

Boolean Values and Operators

John Smith asked what TRUE and FALSE were in PowerShell on our newsgroup Microsoft.Public.Windows.PowerShell.   The simple answer to this is $TRUE and $FALSE but the complete answer is a richer.  PowerShell has a very rich notion of TRUE and FALSE.  The best way to explain it is to show it.  PS>  function...

Jingle

As an attempt to spread some holiday joy, Satish Mathew and I wrote the following script.  Hope you enjoy it!  - Marcel Ortiz  ######################################################################################## $notes = write-output `  4A4 4A4 2A4        4A4 4A4 2A4  &...

Apologizes for delays in approving comments

We had a bad windstorm here and most people have been without power since Thursday night.  Microsoft was closed on Friday and power got restored sometime during the weekend.  Jeffrey Snover [MSFT]Windows PowerShell/Aspen ArchitectVisit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShellVisit ...

ConfirmPreference

With Windows PowerShell you can specify -CONFIRM on commands that have a side-effect on the system and it will ask you whether to perfmon the action or not.  e.g. PS> Stop-Process 7004 -Confirm ConfirmAre you sure you want to perform this action?Performing operation "Stop-Process" on Target "calc (7004)".[Y] Yes  [A] Yes to All&...

KB: 1024 vs 1000

I love the fact that we designed PowerShell for Admins and IT Pros and love to demonstrate what that means.  Often I'll demo PowerShell and show how you can use "KB", "MB", and "GB" as I did in my previous blog entry: PS> 1kb1024PS> 1mb1048576PS> 1gb1073741824PS> 1kb+2mb+3gb3223323648 Almost uniformly, the crowds LOVE ...

File Aging Script

Jeffery Hicks as a very nice File Aging script.  The thing that Iike about it is that it provides a very good illustration of how to use a number of PowerShell features including: He had one technique that could be improved.  Here is a line from the script:  $GrandTotal="{0:N2}" -f ($GrandTotal/1048576) The question is, ...

[SWITCH]

Here is a pointer to a good demonstration of PowerShell's [SWITCH] datatype: http://msgoodies.blogspot.com/2006/12/negating-powershell-switch-parameters.html Jeffrey Snover [MSFT]Windows PowerShell/MMC ArchitectVisit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter...

$OutputEncoding to the rescue

You might have noticed that “findstr” does not work properly with non-English text in PowerShell. For example: Let’s create a text file with some Chinese characters in it. PS C:\> ${c:\test.txt}="中文" Try to use findstr to find  one of the Chinese characters, and it did not find anything. PS C:\> Get-Content test.txt | ...

Windows PowerShell SDK

Windows PowerShell Software Development Kit (SDK) is now available as part of Microsoft Windows SDK for Windows Vista. Microsoft Windows SDK can be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyId=C2B1E300-F358-4523-B479-F53D234CDCCF&displaylang=en Windows PowerShell SDK contains: The documentation can also be...