PowerShell Team

Automating the world one-liner at a time…

The Wonders of Date Math using Windows PowerShell

Larry Hayden posted a query about dates at:http://techtasks.com/bookmarks/powershell/2006/09/interview-with-a-scripter-jeffrey-snover/ He has a script which gets all the Application Events that happened TODAY: ————————————————————$today = [DateTime]::Today$Events = Get-Eventlog -New 1024 Application | ...

Casting a scriptblock to an arbitrary delegate signature

Arild asked the following in http://arildf.spaces.msn.com/blog/cns!E99F8B43533149B0!140.entry?_c%3dBlogPart : PSMDTAG:FAQ: Delegates - how to cast a scriptblock to an arbitrary delegate signature? ANSWER - You can't in V1.0. In version 1.0 Windows PowerShell only supports casting scriptblocks to delegates with the ...

Cascading Type Casts

A user on the newsgroup wondered whether the example below highlighted a bug or a feature.  They applied multiple type declarations on a single parameter and Windows PowerShell did not complain. function check {   param([string] [int] $y = 0, $x = 0)###^^^^^^^^^^^^  $x.GetType().ToString();  $y.GetType().ToString();  $...

Type Shortcuts

PSMDTAG:FAQ: What is a TYPE SHORTCUT?PSMDTAG:FAQ: What are the TYPE SHORTCUTS?   Type shortcuts are a Windows PowerShell feature that allows you to reduce the amount of typing you have to do when specifying a type.    For example, the following 2 statements produce the same result: [System.Text.RegularExpressions.Regex]"^c.*" [...

Using Format Control Strings.

PSMDTAG:FAQ: How do I display large numbers with commas?PSMDTAG:FAQ: How do I use .NET formatting strings? As scripters, we often spend tons of times trying to get our data formated just the right way.  Often this is an error-prone, frustrating experience.  Windows PowerShell leverages .NET objects to make this task a ton simpler.&...

Exposing the Power of .NET in a Admin-friendly way

One of our primary goals for Monad was to:  "Expose the power of .NET in an Admin-friendly way".  The challenges of systems administration are large and growing at the same time organizations are under ever more pressure to reduce costs and do more with less.  That was true 10 years ago, it is true now, it will be true 10 years...

Base64 Encode/Decode a string

Today I came across http://scripts.readify.net/  . This sight is focused on Monad and MSH and is starting a collection of scripts at: http://scripts.readify.net/Scripts.aspx .  You should visit their site and let them know what type of scripts would be useful to you.  I particularly liked their entry on how to Base64 ...

Comparative Examples in MSH and KSH

  Most shells (such as Windows CMD.EXE and the UNIX shells SH, KSH, CSH, and BASH) operate by executing a command or utility in a new process, and presenting the results (or errors) to the user as text. Text-based processing is the way in which system interaction is done with these shells. Over the years, a large number of text ...